From 58912f68c2489bcee787599837447e0d64dfd61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 24 May 2017 21:03:56 +0200 Subject: New upstream version 1.0.27 --- backend/Makefile.am | 78 +- backend/Makefile.in | 172 +-- backend/agfafocus.c | 4 +- backend/apple.c | 4 +- backend/artec.c | 9 +- backend/artec_eplus48u.c | 18 +- backend/as6e.c | 4 +- backend/avision.c | 44 +- backend/avision.h | 1 + backend/bh.h | 2 +- backend/canon-sane.c | 19 +- backend/canon-scsi.c | 4 +- backend/canon.h | 6 - backend/canon630u-common.c | 10 +- backend/canon630u.c | 3 +- backend/canon_dr.c | 1655 +++++++--------------------- backend/canon_dr.conf.in | 5 + backend/canon_dr.h | 58 +- backend/cardscan.c | 24 +- backend/cardscan.conf.in | 3 + backend/coolscan.c | 24 +- backend/coolscan2.c | 3 +- backend/coolscan3.c | 18 +- backend/dc210.c | 3 - backend/dc240.c | 21 +- backend/dc240.h | 6 - backend/dc25.c | 18 +- backend/dc25.h | 6 - backend/dell1600n_net.c | 17 +- backend/dll.c | 30 +- backend/dll.conf.in | 10 +- backend/dmc.c | 3 +- backend/epjitsu-cmd.h | 70 +- backend/epjitsu.c | 324 ++++-- backend/epjitsu.conf.in | 15 +- backend/epjitsu.h | 16 +- backend/epson.c | 9 +- backend/epson2-io.c | 48 +- backend/epson2-ops.c | 17 - backend/epson2.h | 7 - backend/epson2_net.c | 4 +- backend/epson2_scsi.c | 2 +- backend/epsonds-cmd.c | 53 +- backend/epsonds-io.c | 35 +- backend/epsonds-io.h | 2 +- backend/epsonds-jpeg.c | 6 +- backend/epsonds-jpeg.h | 2 - backend/epsonds-net.c | 278 +++++ backend/epsonds-net.h | 16 + backend/epsonds-ops.c | 23 +- backend/epsonds-ops.h | 4 +- backend/epsonds.c | 178 +++- backend/epsonds.conf.in | 4 + backend/epsonds.h | 13 +- backend/fujitsu-scsi.h | 55 +- backend/fujitsu.c | 629 ++++++----- backend/fujitsu.conf.in | 110 +- backend/fujitsu.h | 10 +- backend/genesys.c | 104 +- backend/genesys.conf.in | 2 +- backend/genesys_conv.c | 30 +- backend/genesys_devices.c | 2428 +++++++++++++++++++++--------------------- backend/genesys_gl124.c | 460 +++++--- backend/genesys_gl124.h | 284 ++--- backend/genesys_gl646.c | 29 +- backend/genesys_gl646.h | 10 +- backend/genesys_gl841.c | 125 +-- backend/genesys_gl841.h | 2 +- backend/genesys_gl843.c | 127 +-- backend/genesys_gl843.h | 6 +- backend/genesys_gl846.c | 115 +- backend/genesys_gl846.h | 2 +- backend/genesys_gl847.c | 151 ++- backend/genesys_gl847.h | 2 +- backend/genesys_low.c | 68 +- backend/genesys_low.h | 17 +- backend/gphoto2.c | 38 +- backend/gphoto2.h | 6 - backend/gt68xx.c | 2 +- backend/gt68xx_low.h | 5 +- backend/hp-accessor.c | 8 +- backend/hp-device.c | 2 - backend/hp-handle.c | 2 +- backend/hp-option.c | 94 +- backend/hp-scl.c | 10 +- backend/hp.c | 6 +- backend/hp.h | 6 - backend/hp3500.c | 836 +++++++++++---- backend/hp3900_sane.c | 2 +- backend/hp4200.c | 9 +- backend/hp5400.c | 3 + backend/hp5400_internal.c | 4 +- backend/hp5590.c | 59 +- backend/hp5590_cmds.c | 86 +- backend/hp5590_low.c | 106 +- backend/hpsj5s.c | 2 - backend/hs2p-saneopts.h | 2 +- backend/hs2p-scsi.c | 2 +- backend/kodak.c | 11 +- backend/kodakaio.c | 56 +- backend/kodakaio.h | 6 - backend/kvs1025.conf.in | 2 + backend/kvs20xx.c | 9 +- backend/kvs20xx.h | 6 + backend/kvs20xx_cmd.c | 27 +- backend/kvs20xx_cmd.h | 4 + backend/kvs20xx_opt.c | 1 + backend/kvs40xx.h | 15 + backend/kvs40xx_cmd.c | 26 +- backend/kvs40xx_opt.c | 53 +- backend/lexmark_low.c | 3 + backend/ma1509.c | 3 - backend/magicolor.c | 11 +- backend/magicolor.h | 7 - backend/microtek2.c | 40 +- backend/microtek2.h | 2 +- backend/mustek.c | 16 +- backend/mustek_pp.c | 2 +- backend/mustek_pp_cis.c | 4 +- backend/mustek_usb.c | 2 +- backend/mustek_usb2.c | 11 - backend/mustek_usb2_asic.c | 20 +- backend/mustek_usb2_high.c | 2 - backend/nec.c | 3 +- backend/net.c | 6 +- backend/niash.c | 2 +- backend/niash_core.c | 7 +- backend/p5_device.c | 24 +- backend/pie.c | 6 +- backend/pieusb.c | 89 +- backend/pieusb.conf.in | 19 +- backend/pieusb.h | 1 + backend/pieusb_buffer.c | 11 +- backend/pieusb_scancmd.c | 120 +-- backend/pieusb_scancmd.h | 2 +- backend/pieusb_specific.c | 48 +- backend/pieusb_specific.h | 11 +- backend/pixma.c | 31 +- backend/pixma.conf.in | 15 +- backend/pixma.h | 12 +- backend/pixma_bjnp.c | 183 +++- backend/pixma_bjnp.h | 7 +- backend/pixma_bjnp_private.h | 4 +- backend/pixma_common.c | 18 +- backend/pixma_common.h | 3 +- backend/pixma_imageclass.c | 170 ++- backend/pixma_io.h | 4 +- backend/pixma_io_sanei.c | 2 +- backend/pixma_mp150.c | 46 +- backend/pixma_mp730.c | 56 +- backend/pixma_mp750.c | 2 +- backend/pixma_mp810.c | 9 +- backend/pixma_sane_options.c | 17 + backend/pixma_sane_options.h | 1 + backend/plustek.c | 10 +- backend/plustek_pp.c | 8 +- backend/pnm.c | 2 +- backend/rts8891.c | 12 +- backend/rts88xx_lib.c | 4 +- backend/sharp.c | 7 +- backend/sm3600.c | 9 +- backend/sm3840.c | 0 backend/sm3840.h | 0 backend/sm3840_lib.c | 32 +- backend/sm3840_lib.h | 0 backend/sm3840_scan.c | 70 +- backend/snapscan-mutex.c | 4 +- backend/snapscan-sources.c | 24 +- backend/snapscan.c | 20 +- backend/sp15c.c | 2 +- backend/stv680.conf.in | 0 backend/stv680.h | 0 backend/tamarack.c | 4 +- backend/test.c | 6 +- backend/u12-hw.c | 2 - backend/u12.c | 10 +- backend/umax.c | 14 +- backend/umax1220u.c | 3 +- backend/umax_pp.c | 8 +- backend/umax_pp.h | 9 +- backend/umax_pp_low.c | 123 +-- backend/v4l.c | 18 +- backend/xerox_mfp-tcp.c | 132 +-- backend/xerox_mfp-usb.c | 126 +-- backend/xerox_mfp.c | 2236 ++++++++++++++++++++------------------ backend/xerox_mfp.conf.in | 36 + backend/xerox_mfp.h | 215 ++-- 187 files changed, 7408 insertions(+), 6470 deletions(-) create mode 100644 backend/epsonds-net.c create mode 100644 backend/epsonds-net.h create mode 100644 backend/kvs1025.conf.in mode change 100755 => 100644 backend/sm3840.c mode change 100755 => 100644 backend/sm3840.h mode change 100755 => 100644 backend/sm3840_lib.c mode change 100755 => 100644 backend/sm3840_lib.h mode change 100755 => 100644 backend/sm3840_scan.c mode change 100755 => 100644 backend/stv680.conf.in mode change 100755 => 100644 backend/stv680.h (limited to 'backend') diff --git a/backend/Makefile.am b/backend/Makefile.am index b672490..f7fb403 100644 --- a/backend/Makefile.am +++ b/backend/Makefile.am @@ -4,33 +4,9 @@ ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. -INSTALL_LOCKPATH = @INSTALL_LOCKPATH@ -LOCKPATH_GROUP = @LOCKPATH_GROUP@ - -BACKEND_LIBS_ENABLED=@BACKEND_LIBS_ENABLED@ -BACKEND_CONFS_ENABLED=@BACKEND_CONFS_ENABLED@ - -DL_LIBS = @DL_LIBS@ -LIBV4L_LIBS = @LIBV4L_LIBS@ -MATH_LIB = @MATH_LIB@ -IEEE1284_LIBS = @IEEE1284_LIBS@ -TIFF_LIBS = @TIFF_LIBS@ -JPEG_LIBS = @JPEG_LIBS@ -GPHOTO2_LIBS = @GPHOTO2_LIBS@ -GPHOTO2_LDFLAGS = @GPHOTO2_LDFLAGS@ -SOCKET_LIBS = @SOCKET_LIBS@ -AVAHI_LIBS = @AVAHI_LIBS@ -USB_LIBS = @USB_LIBS@ -SCSI_LIBS = @SCSI_LIBS@ -PTHREAD_LIBS = @PTHREAD_LIBS@ - -AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -DLIBDIR="\"$(libdir)/sane\"" - -V_MAJOR = @V_MAJOR@ -V_MINOR = @V_MINOR@ -V_REV = @V_REV@ - -AM_LDFLAGS = @STRICT_LDFLAGS@ +AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include $(USB_CFLAGS) -DLIBDIR="\"$(libdir)/sane\"" + +AM_LDFLAGS += $(STRICT_LDFLAGS) # The -rpath option is added because we are creating _LTLIBRARIES based # on configure substitution. This causes automake to not know the # correct $libdir and must be added here. @@ -38,7 +14,7 @@ DIST_SANELIBS_LDFLAGS = $(AM_LDFLAGS) -rpath '$(libdir)/sane' -version-number $( DIST_LIBS_LDFLAGS = $(AM_LDFLAGS) -rpath '$(libdir)' -version-number $(V_MAJOR):$(V_MINOR):$(V_REV) # LIBTOOL install is a little to noisy for my liking. -LIBTOOL = @LIBTOOL@ --silent +LIBTOOL += --silent FIRMWARE_DIRS = artec_eplus48u gt68xx snapscan epjitsu EXTRA_DIST = sane_strstatus.c @@ -50,15 +26,15 @@ EXTRA_DIST += stubs.c # FIXME: % is a GNU extension... This is only thing left requiring # use to use GNU make. %-s.c: $(srcdir)/stubs.c - rm -f $@ - $(LN_S) $(srcdir)/stubs.c $@ + $(AM_V_at)rm -f $@ + $(AM_V_at)$(LN_S) $(srcdir)/stubs.c $@ dll-preload.h: - rm -f $@ - list="$(PRELOADABLE_BACKENDS)"; for be in $$list; do \ + $(AM_V_at)rm -f $@ + $(AM_V_at)list="$(PRELOADABLE_BACKENDS)"; for be in $$list; do \ echo "PRELOAD_DECL($$be)" >> $@; \ - done - echo "static struct backend preloaded_backends[] = {" >> $@ + done; \ + echo "static struct backend preloaded_backends[] = {" >> $@; \ sep=""; \ list="$(PRELOADABLE_BACKENDS)"; \ if test -z "$${list}"; then \ @@ -68,7 +44,7 @@ dll-preload.h: echo "$${sep}PRELOAD_DEFN($$be)" >> $@; \ sep=","; \ done; \ - fi + fi; \ echo "};" >> $@ # TODO: This really belongs together with the saned sources and @@ -86,6 +62,7 @@ BACKEND_CONFS= abaton.conf agfafocus.conf apple.conf artec.conf \ epson.conf epsonds.conf fujitsu.conf genesys.conf gphoto2.conf \ gt68xx.conf hp3900.conf hp4200.conf hp5400.conf \ hp.conf hpsj5s.conf hs2p.conf ibm.conf kodak.conf kodakaio.conf\ + kvs1025.conf \ leo.conf lexmark.conf ma1509.conf magicolor.conf \ matsushita.conf microtek2.conf microtek.conf mustek.conf \ mustek_pp.conf mustek_usb.conf nec.conf net.conf \ @@ -351,7 +328,7 @@ libcanon_dr_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon_dr nodist_libsane_canon_dr_la_SOURCES = canon_dr-s.c libsane_canon_dr_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon_dr libsane_canon_dr_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_canon_dr_la_LIBADD = $(COMMON_LIBS) libcanon_dr.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) +libsane_canon_dr_la_LIBADD = $(COMMON_LIBS) libcanon_dr.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_magic.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += canon_dr.conf.in libcanon_pp_la_SOURCES = canon_pp.c canon_pp.h canon_pp-io.c canon_pp-io.h canon_pp-dev.c canon_pp-dev.h @@ -414,7 +391,7 @@ libdc210_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc210 nodist_libsane_dc210_la_SOURCES = dc210-s.c libsane_dc210_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc210 libsane_dc210_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_dc210_la_LIBADD = $(COMMON_LIBS) libdc210.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) +libsane_dc210_la_LIBADD = $(COMMON_LIBS) libdc210.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(SANEI_SANEI_JPEG_LO) $(JPEG_LIBS) EXTRA_DIST += dc210.conf.in libdc240_la_SOURCES = dc240.c dc240.h @@ -423,7 +400,7 @@ libdc240_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc240 nodist_libsane_dc240_la_SOURCES = dc240-s.c libsane_dc240_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc240 libsane_dc240_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_dc240_la_LIBADD = $(COMMON_LIBS) libdc240.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) +libsane_dc240_la_LIBADD = $(COMMON_LIBS) libdc240.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(SANEI_SANEI_JPEG_LO) $(JPEG_LIBS) EXTRA_DIST += dc240.conf.in libdell1600n_net_la_SOURCES = dell1600n_net.c @@ -472,7 +449,8 @@ libsane_epson2_la_LIBADD = $(COMMON_LIBS) libepson2.la ../sanei/sanei_init_debug EXTRA_DIST += epson2.conf.in libepsonds_la_SOURCES = epsonds.c epsonds.h epsonds-usb.c epsonds-usb.h epsonds-io.c epsonds-io.h \ - epsonds-cmd.c epsonds-cmd.h epsonds-ops.c epsonds-ops.h epsonds-jpeg.c epsonds-jpeg.h + epsonds-cmd.c epsonds-cmd.h epsonds-ops.c epsonds-ops.h epsonds-jpeg.c epsonds-jpeg.h \ + epsonds-net.c epsonds-net.h libepsonds_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epsonds nodist_libsane_epsonds_la_SOURCES = epsonds-s.c @@ -481,7 +459,8 @@ libsane_epsonds_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_epsonds_la_LIBADD = $(COMMON_LIBS) libepsonds.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \ ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo \ ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo \ - @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) $(USB_LIBS) $(MATH_LIB) $(RESMGR_LIBS) + ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo \ + $(SANEI_SANEI_JPEG_LO) $(JPEG_LIBS) $(USB_LIBS) $(MATH_LIB) $(RESMGR_LIBS) $(SOCKET_LIBS) EXTRA_DIST += epsonds.conf.in libfujitsu_la_SOURCES = fujitsu.c fujitsu.h fujitsu-scsi.h @@ -505,12 +484,12 @@ EXTRA_DIST += genesys.conf.in EXTRA_DIST += genesys_conv.c genesys_conv_hlp.c genesys_devices.c libgphoto2_i_la_SOURCES = gphoto2.c gphoto2.h -libgphoto2_i_la_CPPFLAGS = $(AM_CPPFLAGS) @GPHOTO2_CPPFLAGS@ -DBACKEND_NAME=gphoto2 +libgphoto2_i_la_CPPFLAGS = $(AM_CPPFLAGS) $(GPHOTO2_CPPFLAGS) -DBACKEND_NAME=gphoto2 nodist_libsane_gphoto2_la_SOURCES = gphoto2-s.c libsane_gphoto2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=gphoto2 libsane_gphoto2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_gphoto2_la_LIBADD = $(GPHOTO2_LDFLAGS) $(COMMON_LIBS) libgphoto2_i.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(GPHOTO2_LIBS) $(JPEG_LIBS) +libsane_gphoto2_la_LIBADD = $(GPHOTO2_LDFLAGS) $(COMMON_LIBS) libgphoto2_i.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(SANEI_SANEI_JPEG_LO) $(GPHOTO2_LIBS) $(JPEG_LIBS) EXTRA_DIST += gphoto2.conf.in libgt68xx_la_SOURCES = gt68xx.c gt68xx.h @@ -541,7 +520,7 @@ libhp3500_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3500 nodist_libsane_hp3500_la_SOURCES = hp3500-s.c libsane_hp3500_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3500 libsane_hp3500_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_hp3500_la_LIBADD = $(COMMON_LIBS) libhp3500.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_thread.lo $(USB_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) +libsane_hp3500_la_LIBADD = $(COMMON_LIBS) libhp3500.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_thread.lo $(MATH_LIB) $(USB_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) libhp3900_la_SOURCES = hp3900.c libhp3900_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3900 @@ -651,6 +630,7 @@ nodist_libsane_kvs1025_la_SOURCES = kvs1025-s.c libsane_kvs1025_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kvs1025 libsane_kvs1025_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_kvs1025_la_LIBADD = $(COMMON_LIBS) libkvs1025.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_magic.lo $(MATH_LIB) $(USB_LIBS) $(RESMGR_LIBS) +EXTRA_DIST += kvs1025.conf.in libkvs20xx_la_SOURCES = kvs20xx.c kvs20xx_cmd.c kvs20xx_opt.c \ kvs20xx_cmd.h kvs20xx.h @@ -788,10 +768,10 @@ libsane_nec_la_LIBADD = $(COMMON_LIBS) libnec.la ../sanei/sanei_init_debug.lo .. EXTRA_DIST += nec.conf.in libnet_la_SOURCES = net.c net.h -libnet_la_CPPFLAGS = $(AM_CPPFLAGS) @AVAHI_CFLAGS@ -DBACKEND_NAME=net +libnet_la_CPPFLAGS = $(AM_CPPFLAGS) $(AVAHI_CFLAGS) -DBACKEND_NAME=net nodist_libsane_net_la_SOURCES = net-s.c -libsane_net_la_CPPFLAGS = $(AM_CPPFLAGS) @AVAHI_CFLAGS@ -DBACKEND_NAME=net +libsane_net_la_CPPFLAGS = $(AM_CPPFLAGS) $(AVAHI_CFLAGS) -DBACKEND_NAME=net libsane_net_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_net_la_LIBADD = $(COMMON_LIBS) libnet.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo $(AVAHI_LIBS) $(SOCKET_LIBS) EXTRA_DIST += net.conf.in @@ -1088,7 +1068,7 @@ libsane_umax_pp_la_LIBADD = $(COMMON_LIBS) libumax_pp.la ../sanei/sanei_init_deb EXTRA_DIST += umax_pp.conf.in libv4l_la_SOURCES = v4l.c v4l.h v4l-frequencies.h -libv4l_la_CPPFLAGS = $(AM_CPPFLAGS) @LIBV4L_CFLAGS@ -DBACKEND_NAME=v4l +libv4l_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBV4L_CFLAGS) -DBACKEND_NAME=v4l nodist_libsane_v4l_la_SOURCES = v4l-s.c libsane_v4l_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=v4l @@ -1102,7 +1082,7 @@ libxerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp nodist_libsane_xerox_mfp_la_SOURCES = xerox_mfp-s.c libsane_xerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp libsane_xerox_mfp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS) +libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += xerox_mfp.conf.in libdll_preload_la_SOURCES = dll.c @@ -1142,7 +1122,7 @@ EXTRA_DIST += dll.aliases nodist_libsane_la_SOURCES = dll-s.c libsane_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dll libsane_la_LDFLAGS = $(DIST_LIBS_LDFLAGS) -libsane_la_LIBADD = $(COMMON_LIBS) @PRELOADABLE_BACKENDS_ENABLED@ libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo $(DL_LIBS) $(LIBV4L_LIBS) $(MATH_LIB) $(IEEE1284_LIBS) $(TIFF_LIBS) $(JPEG_LIBS) $(GPHOTO2_LIBS) $(SOCKET_LIBS) $(USB_LIBS) $(AVAHI_LIBS) $(SCSI_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) +libsane_la_LIBADD = $(COMMON_LIBS) $(PRELOADABLE_BACKENDS_ENABLED) libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo $(DL_LIBS) $(LIBV4L_LIBS) $(MATH_LIB) $(IEEE1284_LIBS) $(TIFF_LIBS) $(JPEG_LIBS) $(GPHOTO2_LIBS) $(SOCKET_LIBS) $(USB_LIBS) $(AVAHI_LIBS) $(SCSI_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) # WARNING: Automake is getting this wrong so have to do it ourselves. -libsane_la_DEPENDENCIES = $(COMMON_LIBS) @PRELOADABLE_BACKENDS_ENABLED@ libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo @SANEI_SANEI_JPEG_LO@ +libsane_la_DEPENDENCIES = $(COMMON_LIBS) $(PRELOADABLE_BACKENDS_ENABLED) libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo $(SANEI_SANEI_JPEG_LO) diff --git a/backend/Makefile.in b/backend/Makefile.in index 1860295..4e070f0 100644 --- a/backend/Makefile.in +++ b/backend/Makefile.in @@ -82,11 +82,16 @@ subdir = backend DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/mkinstalldirs $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ltoptions.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/byteorder.m4 \ - $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.in + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/byteorder.m4 $(top_srcdir)/m4/stdint.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -215,7 +220,7 @@ libepsonds_la_LIBADD = am_libepsonds_la_OBJECTS = libepsonds_la-epsonds.lo \ libepsonds_la-epsonds-usb.lo libepsonds_la-epsonds-io.lo \ libepsonds_la-epsonds-cmd.lo libepsonds_la-epsonds-ops.lo \ - libepsonds_la-epsonds-jpeg.lo + libepsonds_la-epsonds-jpeg.lo libepsonds_la-epsonds-net.lo libepsonds_la_OBJECTS = $(am_libepsonds_la_OBJECTS) libfujitsu_la_LIBADD = am_libfujitsu_la_OBJECTS = libfujitsu_la-fujitsu.lo @@ -491,8 +496,9 @@ libsane_canon_dr_la_DEPENDENCIES = $(COMMON_LIBS) libcanon_dr.la \ ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \ ../sanei/sanei_config.lo ../sanei/sanei_config2.lo \ sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo \ + ../sanei/sanei_magic.lo $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) nodist_libsane_canon_dr_la_OBJECTS = \ libsane_canon_dr_la-canon_dr-s.lo libsane_canon_dr_la_OBJECTS = $(nodist_libsane_canon_dr_la_OBJECTS) @@ -567,7 +573,7 @@ libsane_coolscan3_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ libsane_dc210_la_DEPENDENCIES = $(COMMON_LIBS) libdc210.la \ ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \ ../sanei/sanei_config.lo sane_strstatus.lo \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) nodist_libsane_dc210_la_OBJECTS = libsane_dc210_la-dc210-s.lo libsane_dc210_la_OBJECTS = $(nodist_libsane_dc210_la_OBJECTS) libsane_dc210_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ @@ -577,7 +583,7 @@ libsane_dc210_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ libsane_dc240_la_DEPENDENCIES = $(COMMON_LIBS) libdc240.la \ ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \ ../sanei/sanei_config.lo sane_strstatus.lo \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) nodist_libsane_dc240_la_OBJECTS = libsane_dc240_la-dc240-s.lo libsane_dc240_la_OBJECTS = $(nodist_libsane_dc240_la_OBJECTS) libsane_dc240_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ @@ -669,6 +675,8 @@ libsane_epsonds_la_DEPENDENCIES = $(COMMON_LIBS) libepsonds.la \ ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \ ../sanei/sanei_config.lo ../sanei/sanei_config2.lo \ sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo \ + ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) nodist_libsane_epsonds_la_OBJECTS = libsane_epsonds_la-epsonds-s.lo @@ -704,7 +712,8 @@ libsane_genesys_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ libsane_gphoto2_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(COMMON_LIBS) \ libgphoto2_i.la ../sanei/sanei_init_debug.lo \ ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo \ - sane_strstatus.lo $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + sane_strstatus.lo $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) nodist_libsane_gphoto2_la_OBJECTS = libsane_gphoto2_la-gphoto2-s.lo libsane_gphoto2_la_OBJECTS = $(nodist_libsane_gphoto2_la_OBJECTS) libsane_gphoto2_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ @@ -739,7 +748,7 @@ libsane_hp3500_la_DEPENDENCIES = $(COMMON_LIBS) libhp3500.la \ ../sanei/sanei_config.lo sane_strstatus.lo \ ../sanei/sanei_usb.lo ../sanei/sanei_thread.lo \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) nodist_libsane_hp3500_la_OBJECTS = libsane_hp3500_la-hp3500-s.lo libsane_hp3500_la_OBJECTS = $(nodist_libsane_hp3500_la_OBJECTS) libsane_hp3500_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ @@ -1421,9 +1430,10 @@ libsane_v4l_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ libsane_xerox_mfp_la_DEPENDENCIES = $(COMMON_LIBS) libxerox_mfp.la \ ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \ ../sanei/sanei_config.lo sane_strstatus.lo \ - ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo \ + $(am__DEPENDENCIES_1) ../sanei/sanei_usb.lo \ + ../sanei/sanei_tcp.lo $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) nodist_libsane_xerox_mfp_la_OBJECTS = \ libsane_xerox_mfp_la-xerox_mfp-s.lo libsane_xerox_mfp_la_OBJECTS = $(nodist_libsane_xerox_mfp_la_OBJECTS) @@ -1740,7 +1750,12 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CPPFLAGS = @AM_CPPFLAGS@ -I. -I$(srcdir) -I$(top_builddir)/include \ + -I$(top_srcdir)/include $(USB_CFLAGS) \ + -DLIBDIR="\"$(libdir)/sane\"" AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AM_LDFLAGS = @AM_LDFLAGS@ $(STRICT_LDFLAGS) AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ @@ -1761,9 +1776,9 @@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DISTCLEAN_FILES = @DISTCLEAN_FILES@ +DLH = @DLH@ DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ +DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ @@ -1774,48 +1789,56 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FIG2DEV = @FIG2DEV@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ GPHOTO2_CPPFLAGS = @GPHOTO2_CPPFLAGS@ GPHOTO2_LDFLAGS = @GPHOTO2_LDFLAGS@ GPHOTO2_LIBS = @GPHOTO2_LIBS@ GREP = @GREP@ +GS = @GS@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ -IEEE1284_LIBS = @IEEE1284_LIBS@ -INCLUDES = @INCLUDES@ +IEEE1284_LIBS = @IEEE1284_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_LOCKPATH = @INSTALL_LOCKPATH@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -JPEG_LIBS = @JPEG_LIBS@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JPEG_LIBS = @JPEG_LIBS@ LATEX = @LATEX@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ # LIBTOOL install is a little to noisy for my liking. LIBTOOL = @LIBTOOL@ --silent -LIBUSB_1_0_CFLAGS = @LIBUSB_1_0_CFLAGS@ -LIBUSB_1_0_LIBS = @LIBUSB_1_0_LIBS@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ -LIBV4L_LIBS = @LIBV4L_LIBS@ -LINKER_RPATH = @LINKER_RPATH@ +LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ +LTALLOCA = @LTALLOCA@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ -MATH_LIB = @MATH_LIB@ +MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ -NUMBER_VERSION = @NUMBER_VERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ @@ -1828,10 +1851,13 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PDFLATEX = @PDFLATEX@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PNG_LIBS = @PNG_LIBS@ +POSUB = @POSUB@ +PPMTOGIF = @PPMTOGIF@ PRELOADABLE_BACKENDS = @PRELOADABLE_BACKENDS@ PRELOADABLE_BACKENDS_ENABLED = @PRELOADABLE_BACKENDS_ENABLED@ PTHREAD_LIBS = @PTHREAD_LIBS@ @@ -1846,19 +1872,23 @@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_LIBS@ -SOCKET_LIBS = @SOCKET_LIBS@ +SOCKET_LIBS = @SOCKET_LIBS@ STRICT_LDFLAGS = @STRICT_LDFLAGS@ STRIP = @STRIP@ SYSLOG_LIBS = @SYSLOG_LIBS@ SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ SYSTEMD_LIBS = @SYSTEMD_LIBS@ -TIFF_LIBS = @TIFF_LIBS@ -USB_LIBS = @USB_LIBS@ +TIFF_LIBS = @TIFF_LIBS@ +USB_CFLAGS = @USB_CFLAGS@ +USB_LIBS = @USB_LIBS@ +USE_NLS = @USE_NLS@ VERSION = @VERSION@ V_MAJOR = @V_MAJOR@ V_MINOR = @V_MINOR@ V_REV = @V_REV@ XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -1914,8 +1944,6 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -DLIBDIR="\"$(libdir)/sane\"" -AM_LDFLAGS = @STRICT_LDFLAGS@ # The -rpath option is added because we are creating _LTLIBRARIES based # on configure substitution. This causes automake to not know the # correct $libdir and must be added here. @@ -1978,16 +2006,16 @@ EXTRA_DIST = sane_strstatus.c stubs.c saned.conf.in abaton.conf.in \ hp5590_cmds.c hp5590_cmds.h hp5590_low.c hp5590_low.h \ hpsj5s.conf.in hs2p.conf.in hs2p-scsi.c hs2p-scsi.h \ ibm.conf.in ibm-scsi.c kodak.conf.in kodakaio.conf.in \ - leo.conf.in lexmark.conf.in lexmark_models.c lexmark_sensors.c \ - ma1509.conf.in magicolor.conf.in matsushita.conf.in \ - microtek.conf.in microtek2.conf.in mustek.conf.in \ - mustek_scsi_pp.c mustek_scsi_pp.h mustek_pp.conf.in \ - mustek_pp_ccd300.c mustek_pp_ccd300.h mustek_pp_cis.c \ - mustek_pp_cis.h mustek_pp_null.c mustek_usb.conf.in \ - mustek_usb_high.c mustek_usb_high.h mustek_usb_low.c \ - mustek_usb_low.h mustek_usb_mid.c mustek_usb_mid.h \ - mustek_usb2_asic.c mustek_usb2_asic.h mustek_usb2_high.c \ - mustek_usb2_high.h mustek_usb2_reflective.c \ + kvs1025.conf.in leo.conf.in lexmark.conf.in lexmark_models.c \ + lexmark_sensors.c ma1509.conf.in magicolor.conf.in \ + matsushita.conf.in microtek.conf.in microtek2.conf.in \ + mustek.conf.in mustek_scsi_pp.c mustek_scsi_pp.h \ + mustek_pp.conf.in mustek_pp_ccd300.c mustek_pp_ccd300.h \ + mustek_pp_cis.c mustek_pp_cis.h mustek_pp_null.c \ + mustek_usb.conf.in mustek_usb_high.c mustek_usb_high.h \ + mustek_usb_low.c mustek_usb_low.h mustek_usb_mid.c \ + mustek_usb_mid.h mustek_usb2_asic.c mustek_usb2_asic.h \ + mustek_usb2_high.c mustek_usb2_high.h mustek_usb2_reflective.c \ mustek_usb2_transparent.c nec.conf.in net.conf.in niash_core.c \ niash_core.h niash_xfer.c niash_xfer.h pie.conf.in \ pieusb.conf.in p5.conf.in p5_device.c pixma.conf.in \ @@ -2035,6 +2063,7 @@ BACKEND_CONFS = abaton.conf agfafocus.conf apple.conf artec.conf \ epson.conf epsonds.conf fujitsu.conf genesys.conf gphoto2.conf \ gt68xx.conf hp3900.conf hp4200.conf hp5400.conf \ hp.conf hpsj5s.conf hs2p.conf ibm.conf kodak.conf kodakaio.conf\ + kvs1025.conf \ leo.conf lexmark.conf ma1509.conf magicolor.conf \ matsushita.conf microtek2.conf microtek.conf mustek.conf \ mustek_pp.conf mustek_usb.conf nec.conf net.conf \ @@ -2213,7 +2242,7 @@ libcanon_dr_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon_dr nodist_libsane_canon_dr_la_SOURCES = canon_dr-s.c libsane_canon_dr_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon_dr libsane_canon_dr_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_canon_dr_la_LIBADD = $(COMMON_LIBS) libcanon_dr.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) +libsane_canon_dr_la_LIBADD = $(COMMON_LIBS) libcanon_dr.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_magic.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) libcanon_pp_la_SOURCES = canon_pp.c canon_pp.h canon_pp-io.c canon_pp-io.h canon_pp-dev.c canon_pp-dev.h libcanon_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon_pp nodist_libsane_canon_pp_la_SOURCES = canon_pp-s.c @@ -2255,13 +2284,13 @@ libdc210_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc210 nodist_libsane_dc210_la_SOURCES = dc210-s.c libsane_dc210_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc210 libsane_dc210_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_dc210_la_LIBADD = $(COMMON_LIBS) libdc210.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) +libsane_dc210_la_LIBADD = $(COMMON_LIBS) libdc210.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(SANEI_SANEI_JPEG_LO) $(JPEG_LIBS) libdc240_la_SOURCES = dc240.c dc240.h libdc240_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc240 nodist_libsane_dc240_la_SOURCES = dc240-s.c libsane_dc240_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc240 libsane_dc240_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_dc240_la_LIBADD = $(COMMON_LIBS) libdc240.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) +libsane_dc240_la_LIBADD = $(COMMON_LIBS) libdc240.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(SANEI_SANEI_JPEG_LO) $(JPEG_LIBS) libdell1600n_net_la_SOURCES = dell1600n_net.c libdell1600n_net_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dell1600n_net nodist_libsane_dell1600n_net_la_SOURCES = dell1600n_net-s.c @@ -2293,7 +2322,8 @@ libsane_epson2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epson2 libsane_epson2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_epson2_la_LIBADD = $(COMMON_LIBS) libepson2.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo $(SCSI_LIBS) $(USB_LIBS) $(SOCKET_LIBS) $(MATH_LIB) $(RESMGR_LIBS) libepsonds_la_SOURCES = epsonds.c epsonds.h epsonds-usb.c epsonds-usb.h epsonds-io.c epsonds-io.h \ - epsonds-cmd.c epsonds-cmd.h epsonds-ops.c epsonds-ops.h epsonds-jpeg.c epsonds-jpeg.h + epsonds-cmd.c epsonds-cmd.h epsonds-ops.c epsonds-ops.h epsonds-jpeg.c epsonds-jpeg.h \ + epsonds-net.c epsonds-net.h libepsonds_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epsonds nodist_libsane_epsonds_la_SOURCES = epsonds-s.c @@ -2302,7 +2332,8 @@ libsane_epsonds_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_epsonds_la_LIBADD = $(COMMON_LIBS) libepsonds.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \ ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo \ ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo \ - @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) $(USB_LIBS) $(MATH_LIB) $(RESMGR_LIBS) + ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo \ + $(SANEI_SANEI_JPEG_LO) $(JPEG_LIBS) $(USB_LIBS) $(MATH_LIB) $(RESMGR_LIBS) $(SOCKET_LIBS) libfujitsu_la_SOURCES = fujitsu.c fujitsu.h fujitsu-scsi.h libfujitsu_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=fujitsu @@ -2317,11 +2348,11 @@ libsane_genesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys libsane_genesys_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_genesys_la_LIBADD = $(COMMON_LIBS) libgenesys.la ../sanei/sanei_magic.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(MATH_LIB) $(USB_LIBS) $(RESMGR_LIBS) libgphoto2_i_la_SOURCES = gphoto2.c gphoto2.h -libgphoto2_i_la_CPPFLAGS = $(AM_CPPFLAGS) @GPHOTO2_CPPFLAGS@ -DBACKEND_NAME=gphoto2 +libgphoto2_i_la_CPPFLAGS = $(AM_CPPFLAGS) $(GPHOTO2_CPPFLAGS) -DBACKEND_NAME=gphoto2 nodist_libsane_gphoto2_la_SOURCES = gphoto2-s.c libsane_gphoto2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=gphoto2 libsane_gphoto2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_gphoto2_la_LIBADD = $(GPHOTO2_LDFLAGS) $(COMMON_LIBS) libgphoto2_i.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(GPHOTO2_LIBS) $(JPEG_LIBS) +libsane_gphoto2_la_LIBADD = $(GPHOTO2_LDFLAGS) $(COMMON_LIBS) libgphoto2_i.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(SANEI_SANEI_JPEG_LO) $(GPHOTO2_LIBS) $(JPEG_LIBS) libgt68xx_la_SOURCES = gt68xx.c gt68xx.h libgt68xx_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=gt68xx nodist_libsane_gt68xx_la_SOURCES = gt68xx-s.c @@ -2339,7 +2370,7 @@ libhp3500_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3500 nodist_libsane_hp3500_la_SOURCES = hp3500-s.c libsane_hp3500_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3500 libsane_hp3500_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_hp3500_la_LIBADD = $(COMMON_LIBS) libhp3500.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_thread.lo $(USB_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) +libsane_hp3500_la_LIBADD = $(COMMON_LIBS) libhp3500.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_thread.lo $(MATH_LIB) $(USB_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) libhp3900_la_SOURCES = hp3900.c libhp3900_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3900 nodist_libsane_hp3900_la_SOURCES = hp3900-s.c @@ -2497,9 +2528,9 @@ libsane_nec_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=nec libsane_nec_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_nec_la_LIBADD = $(COMMON_LIBS) libnec.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_scsi.lo $(MATH_LIB) $(SCSI_LIBS) $(RESMGR_LIBS) libnet_la_SOURCES = net.c net.h -libnet_la_CPPFLAGS = $(AM_CPPFLAGS) @AVAHI_CFLAGS@ -DBACKEND_NAME=net +libnet_la_CPPFLAGS = $(AM_CPPFLAGS) $(AVAHI_CFLAGS) -DBACKEND_NAME=net nodist_libsane_net_la_SOURCES = net-s.c -libsane_net_la_CPPFLAGS = $(AM_CPPFLAGS) @AVAHI_CFLAGS@ -DBACKEND_NAME=net +libsane_net_la_CPPFLAGS = $(AM_CPPFLAGS) $(AVAHI_CFLAGS) -DBACKEND_NAME=net libsane_net_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_net_la_LIBADD = $(COMMON_LIBS) libnet.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo $(AVAHI_LIBS) $(SOCKET_LIBS) libniash_la_SOURCES = niash.c @@ -2683,7 +2714,7 @@ libsane_umax_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=umax_pp libsane_umax_pp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_umax_pp_la_LIBADD = $(COMMON_LIBS) libumax_pp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(MATH_LIB) libv4l_la_SOURCES = v4l.c v4l.h v4l-frequencies.h -libv4l_la_CPPFLAGS = $(AM_CPPFLAGS) @LIBV4L_CFLAGS@ -DBACKEND_NAME=v4l +libv4l_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBV4L_CFLAGS) -DBACKEND_NAME=v4l nodist_libsane_v4l_la_SOURCES = v4l-s.c libsane_v4l_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=v4l libsane_v4l_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) @@ -2693,7 +2724,7 @@ libxerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp nodist_libsane_xerox_mfp_la_SOURCES = xerox_mfp-s.c libsane_xerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp libsane_xerox_mfp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) -libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS) +libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS) libdll_preload_la_SOURCES = dll.c libdll_preload_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dll -DENABLE_PRELOAD libdll_la_SOURCES = dll.c @@ -2726,10 +2757,10 @@ libsane_dll_la_LIBADD = $(COMMON_LIBS) libdll.la ../sanei/sanei_init_debug.lo .. nodist_libsane_la_SOURCES = dll-s.c libsane_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dll libsane_la_LDFLAGS = $(DIST_LIBS_LDFLAGS) -libsane_la_LIBADD = $(COMMON_LIBS) @PRELOADABLE_BACKENDS_ENABLED@ libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo $(DL_LIBS) $(LIBV4L_LIBS) $(MATH_LIB) $(IEEE1284_LIBS) $(TIFF_LIBS) $(JPEG_LIBS) $(GPHOTO2_LIBS) $(SOCKET_LIBS) $(USB_LIBS) $(AVAHI_LIBS) $(SCSI_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) +libsane_la_LIBADD = $(COMMON_LIBS) $(PRELOADABLE_BACKENDS_ENABLED) libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo $(DL_LIBS) $(LIBV4L_LIBS) $(MATH_LIB) $(IEEE1284_LIBS) $(TIFF_LIBS) $(JPEG_LIBS) $(GPHOTO2_LIBS) $(SOCKET_LIBS) $(USB_LIBS) $(AVAHI_LIBS) $(SCSI_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) # WARNING: Automake is getting this wrong so have to do it ourselves. -libsane_la_DEPENDENCIES = $(COMMON_LIBS) @PRELOADABLE_BACKENDS_ENABLED@ libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo @SANEI_SANEI_JPEG_LO@ +libsane_la_DEPENDENCIES = $(COMMON_LIBS) $(PRELOADABLE_BACKENDS_ENABLED) libdll_preload.la sane_strstatus.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo ../sanei/sanei_net.lo ../sanei/sanei_wire.lo ../sanei/sanei_codec_bin.lo ../sanei/sanei_pa4s2.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pio.lo ../sanei/sanei_tcp.lo ../sanei/sanei_udp.lo ../sanei/sanei_magic.lo $(SANEI_SANEI_JPEG_LO) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am @@ -3428,6 +3459,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libepsonds_la-epsonds-cmd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libepsonds_la-epsonds-io.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libepsonds_la-epsonds-jpeg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libepsonds_la-epsonds-net.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libepsonds_la-epsonds-ops.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libepsonds_la-epsonds-usb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libepsonds_la-epsonds.Plo@am__quote@ @@ -3626,22 +3658,25 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxerox_mfp_la-xerox_mfp.Plo@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< @@ -3947,6 +3982,13 @@ libepsonds_la-epsonds-jpeg.lo: epsonds-jpeg.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libepsonds_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libepsonds_la-epsonds-jpeg.lo `test -f 'epsonds-jpeg.c' || echo '$(srcdir)/'`epsonds-jpeg.c +libepsonds_la-epsonds-net.lo: epsonds-net.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libepsonds_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libepsonds_la-epsonds-net.lo -MD -MP -MF $(DEPDIR)/libepsonds_la-epsonds-net.Tpo -c -o libepsonds_la-epsonds-net.lo `test -f 'epsonds-net.c' || echo '$(srcdir)/'`epsonds-net.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libepsonds_la-epsonds-net.Tpo $(DEPDIR)/libepsonds_la-epsonds-net.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='epsonds-net.c' object='libepsonds_la-epsonds-net.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libepsonds_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libepsonds_la-epsonds-net.lo `test -f 'epsonds-net.c' || echo '$(srcdir)/'`epsonds-net.c + libfujitsu_la-fujitsu.lo: fujitsu.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfujitsu_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libfujitsu_la-fujitsu.lo -MD -MP -MF $(DEPDIR)/libfujitsu_la-fujitsu.Tpo -c -o libfujitsu_la-fujitsu.lo `test -f 'fujitsu.c' || echo '$(srcdir)/'`fujitsu.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libfujitsu_la-fujitsu.Tpo $(DEPDIR)/libfujitsu_la-fujitsu.Plo @@ -5526,15 +5568,15 @@ all: becfg # FIXME: % is a GNU extension... This is only thing left requiring # use to use GNU make. %-s.c: $(srcdir)/stubs.c - rm -f $@ - $(LN_S) $(srcdir)/stubs.c $@ + $(AM_V_at)rm -f $@ + $(AM_V_at)$(LN_S) $(srcdir)/stubs.c $@ dll-preload.h: - rm -f $@ - list="$(PRELOADABLE_BACKENDS)"; for be in $$list; do \ + $(AM_V_at)rm -f $@ + $(AM_V_at)list="$(PRELOADABLE_BACKENDS)"; for be in $$list; do \ echo "PRELOAD_DECL($$be)" >> $@; \ - done - echo "static struct backend preloaded_backends[] = {" >> $@ + done; \ + echo "static struct backend preloaded_backends[] = {" >> $@; \ sep=""; \ list="$(PRELOADABLE_BACKENDS)"; \ if test -z "$${list}"; then \ @@ -5544,7 +5586,7 @@ dll-preload.h: echo "$${sep}PRELOAD_DEFN($$be)" >> $@; \ sep=","; \ done; \ - fi + fi; \ echo "};" >> $@ becfg: $(BACKEND_CONFS) .conf.in.conf: diff --git a/backend/agfafocus.c b/backend/agfafocus.c index 45d103f..c2c5664 100644 --- a/backend/agfafocus.c +++ b/backend/agfafocus.c @@ -947,7 +947,7 @@ do_cancel (AgfaFocus_Scanner * s) do_eof (s); - if (s->reader_pid != -1) + if (sanei_thread_is_valid (s->reader_pid)) { int exit_status; @@ -2054,7 +2054,7 @@ sane_cancel (SANE_Handle handle) { AgfaFocus_Scanner *s = handle; - if (s->reader_pid != -1) + if (sanei_thread_is_valid (s->reader_pid)) sanei_thread_kill (s->reader_pid); s->scanning = SANE_FALSE; } diff --git a/backend/apple.c b/backend/apple.c index a8e9979..487d743 100644 --- a/backend/apple.c +++ b/backend/apple.c @@ -2634,7 +2634,7 @@ sane_cancel (SANE_Handle handle) if (s->AbortedByUser) { DBG (FLOW_CONTROL, - "sane_cancel: Allready Aborted. Please Wait...\n"); + "sane_cancel: Already Aborted. Please Wait...\n"); } else { @@ -2648,7 +2648,7 @@ sane_cancel (SANE_Handle handle) if (s->AbortedByUser) { DBG (FLOW_CONTROL, "sane_cancel: Scan has not been Initiated yet, " - "or it is allready aborted.\n"); + "or it is already aborted.\n"); s->AbortedByUser = SANE_FALSE; sanei_scsi_cmd (s->fd, test_unit_ready, sizeof (test_unit_ready), 0, 0); diff --git a/backend/artec.c b/backend/artec.c index 46aa8b6..2d564a5 100644 --- a/backend/artec.c +++ b/backend/artec.c @@ -1711,7 +1711,6 @@ static SANE_Status artec_get_cap_data (ARTEC_Device * dev, int fd) { int cap_model, loop; - SANE_Status status; u_char cap_buf[256]; /* buffer for cap data */ DBG (7, "artec_get_cap_data()\n"); @@ -1746,11 +1745,11 @@ artec_get_cap_data (ARTEC_Device * dev, int fd) dev->height = cap_data[cap_model].height; - status = artec_str_list_to_word_list (&dev->horz_resolution_list, - cap_data[cap_model].horz_resolution_str); + artec_str_list_to_word_list (&dev->horz_resolution_list, + cap_data[cap_model].horz_resolution_str); - status = artec_str_list_to_word_list (&dev->vert_resolution_list, - cap_data[cap_model].vert_resolution_str); + artec_str_list_to_word_list (&dev->vert_resolution_list, + cap_data[cap_model].vert_resolution_str); dev->contrast_range.min = 0; dev->contrast_range.max = 255; diff --git a/backend/artec_eplus48u.c b/backend/artec_eplus48u.c index bc3b2f8..f31bf5c 100644 --- a/backend/artec_eplus48u.c +++ b/backend/artec_eplus48u.c @@ -1785,14 +1785,14 @@ artec48u_device_read_prepare (Artec48U_Device * dev, size_t expected_count) return SANE_STATUS_GOOD; } -static RETSIGTYPE +static void reader_process_sigterm_handler (int signal) { XDBG ((1, "reader_process: terminated by signal %d\n", signal)); _exit (SANE_STATUS_GOOD); } -static RETSIGTYPE +static void usb_reader_process_sigterm_handler (int signal) { XDBG ((1, "reader_process (usb): terminated by signal %d\n", signal)); @@ -3372,12 +3372,10 @@ close_pipe (Artec48U_Scanner * s) } return SANE_STATUS_EOF; } -static RETSIGTYPE -sigalarm_handler (int signal) +static void +sigalarm_handler (int __sane_unused__ signal) { - int dummy; /*Henning doesn't like warnings :-) */ XDBG ((1, "ALARM!!!\n")); - dummy = signal; cancelRead = SANE_TRUE; } @@ -3483,7 +3481,7 @@ do_cancel (Artec48U_Scanner * s, SANE_Bool closepipe) s->scanning = SANE_FALSE; - if (s->reader_pid != -1) + if (sanei_thread_is_valid (s->reader_pid)) { /*parent */ XDBG ((1, "killing reader_process\n")); @@ -3906,17 +3904,15 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) void sane_close (SANE_Handle handle) { - Artec48U_Scanner *prev, *s; + Artec48U_Scanner *s; XDBG ((5, "sane_close: start\n")); /* remove handle from list of open handles: */ - prev = 0; for (s = first_handle; s; s = s->next) { if (s == handle) break; - prev = s; } if (!s) { @@ -4301,7 +4297,7 @@ sane_start (SANE_Handle handle) s->reader_pipe = fds[1]; s->reader_pid = sanei_thread_begin (reader_process, s); cancelRead = SANE_FALSE; - if (s->reader_pid == -1) + if (!sanei_thread_is_valid (s->reader_pid)) { s->scanning = SANE_FALSE; XDBG ((2, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno))); diff --git a/backend/as6e.c b/backend/as6e.c index 0fb9e31..76241fb 100644 --- a/backend/as6e.c +++ b/backend/as6e.c @@ -576,8 +576,8 @@ as6e_open (AS6E_Scan * s) execlp ("as6edriver", "as6edriver", "-s", inpipe_desc, outpipe_desc, datapipe_desc, (char *) 0); DBG (1, "The SANE backend was unable to start \"as6edriver\".\n"); - DBG (1, "This must be installed in a driectory in your PATH.\n"); - DBG (1, "To aquire the as6edriver program,\n"); + DBG (1, "This must be installed in a directory in your PATH.\n"); + DBG (1, "To acquire the as6edriver program,\n"); DBG (1, "go to http://as6edriver.sourceforge.net.\n"); write (ctlinpipe[WRITEPIPE], &exec_result, sizeof (exec_result)); exit (-1); diff --git a/backend/avision.c b/backend/avision.c index 146125c..61491a2 100644 --- a/backend/avision.c +++ b/backend/avision.c @@ -1277,6 +1277,9 @@ static SANE_Bool force_calibration = SANE_FALSE; static SANE_Bool force_a4 = SANE_FALSE; static SANE_Bool force_a3 = SANE_FALSE; +/* trust ADF-presence flag, even if ADF model is nonzero */ +static SANE_Bool skip_adf = SANE_FALSE; + /* hardware resolutions to interpolate from */ static const int hw_res_list_c5[] = { @@ -2736,7 +2739,7 @@ wait_4_light (Avision_Scanner* s) struct command_read rcmd; char* light_status[] = { "off", "on", "warming up", "needs warm up test", - "light check error", "RESERVED" }; + "light check error", "backlight on", "RESERVED" }; SANE_Status status; uint8_t result; @@ -2753,6 +2756,11 @@ wait_4_light (Avision_Scanner* s) set_triple (rcmd.transferlen, size); for (try = 0; try < 90; ++ try) { + + if (s->cancelled) { + DBG (3, "wait_4_light: cancelled\n"); + return SANE_STATUS_CANCELLED; + } DBG (5, "wait_4_light: read bytes %lu\n", (u_long) size); status = avision_cmd (&s->av_con, &rcmd, sizeof (rcmd), 0, 0, &result, &size); @@ -2762,10 +2770,10 @@ wait_4_light (Avision_Scanner* s) return status; } - DBG (3, "wait_4_light: command is %d. Result is %s\n", - status, light_status[(result>4)?5:result]); + DBG (3, "wait_4_light: command is %d. Result is %d (%s)\n", + status, result, light_status[(result>5)?6:result]); - if (result == 1) { + if (result == 1 || result == 5) { return SANE_STATUS_GOOD; } else if (dev->hw->feature_type & AV_LIGHT_CHECK_BOGUS) { @@ -3218,11 +3226,13 @@ get_accessories_info (Avision_Scanner* s) { dev->inquiry_duplex = 1; dev->inquiry_duplex_interlaced = 0; - } else if (result[0] == 0 && result[2] != 0) { + } else if (result[0] == 0 && result[2] != 0 && !skip_adf) { /* Sometimes the scanner will report that there is no ADF attached, yet * an ADF model number will still be reported. This happens on the * HP8200 series and possibly others. In this case we need to reset the - * the adf and try reading it again. + * the adf and try reading it again. Skip this if the configuration says + * to do so, so that we don't fail out the scanner as being broken and + * unsupported if there isn't actually an ADF present. */ DBG (3, "get_accessories_info: Found ADF model number but the ADF-present flag is not set. Trying to recover...\n"); status = adf_reset (s); @@ -4641,7 +4651,6 @@ set_calib_data (Avision_Scanner* s, struct calibration_format* format, struct command_send scmd; int i; - size_t out_size; DBG (3, "set_calib_data:\n"); @@ -4679,8 +4688,6 @@ set_calib_data (Avision_Scanner* s, struct calibration_format* format, } } - out_size = format->pixel_per_line * 2; - /* send data in one command? */ /* FR: HP5370 reports one-pass, but needs multi (or other format in single) */ if (format->channels == 1 || @@ -6215,8 +6222,9 @@ do_cancel (Avision_Scanner* s) s->prepared = s->scanning = SANE_FALSE; s->duplex_rear_valid = SANE_FALSE; s->page = 0; + s->cancelled = 1; - if (s->reader_pid != -1) { + if (sanei_thread_is_valid (s->reader_pid)) { int exit_status; /* ensure child knows it's time to stop: */ @@ -7630,6 +7638,11 @@ sane_reload_devices (void) linenumber); force_a3 = SANE_TRUE; } + else if (strcmp (word, "skip-adf") == 0) { + DBG (3, "sane_reload_devices: config file line %d: enabling skip-adf\n", + linenumber); + skip_adf = SANE_TRUE; + } else if (strcmp (word, "static-red-calib") == 0) { DBG (3, "sane_reload_devices: config file line %d: static red calibration\n", linenumber); @@ -8313,6 +8326,9 @@ sane_start (SANE_Handle handle) /* Make sure there is no scan running!!! */ if (s->scanning) return SANE_STATUS_DEVICE_BUSY; + + /* Clear cancellation status */ + s->cancelled = 0; /* Make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ @@ -8365,6 +8381,14 @@ sane_start (SANE_Handle handle) sane_strstatus (status)); goto stop_scanner_and_return; } + /* Re-check the light, as setting the window may have changed + * which light is to be turned on. */ + if (s->prepared == SANE_FALSE && dev->inquiry_light_control) { + status = wait_4_light (s); + if (status != SANE_STATUS_GOOD) { + return status; + } + } } #ifdef DEBUG_TEST diff --git a/backend/avision.h b/backend/avision.h index 2122e09..b26907f 100644 --- a/backend/avision.h +++ b/backend/avision.h @@ -444,6 +444,7 @@ typedef struct Avision_Scanner SANE_Bool prepared; /* first page marker */ SANE_Bool scanning; /* scan in progress */ unsigned int page; /* page counter, 0: uninitialized, 1: scanning 1st page, ... */ + int cancelled; SANE_Parameters params; /* scan window */ Avision_Dimensions avdimen; /* scan window - detailed internals */ diff --git a/backend/bh.h b/backend/bh.h index 62115c6..545ffb1 100644 --- a/backend/bh.h +++ b/backend/bh.h @@ -652,7 +652,7 @@ _4btol(SANE_Byte *bytes) #define SANE_NAME_BARCODE_HMIN "barcode-hmin" #define SANE_TITLE_BARCODE_HMIN "Barcode Minimum Height" -#define SANE_DESC_BARCODE_HMIN "Sets the Barcode Minimun Height (larger values increase recognition speed)" +#define SANE_DESC_BARCODE_HMIN "Sets the Barcode Minimum Height (larger values increase recognition speed)" #define SANE_NAME_BARCODE_SEARCH_MODE "barcode-search-mode" #define SANE_TITLE_BARCODE_SEARCH_MODE "Barcode Search Mode" diff --git a/backend/canon-sane.c b/backend/canon-sane.c index 79ce0ba..a8efc7a 100644 --- a/backend/canon-sane.c +++ b/backend/canon-sane.c @@ -1,5 +1,5 @@ SANE_Status -sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize) +sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { char devnam[PATH_MAX] = "/dev/scanner"; FILE *fp; @@ -107,7 +107,7 @@ sane_exit (void) SANE_Status sane_get_devices (const SANE_Device *** device_list, -SANE_Bool UNUSEDARG local_only) +SANE_Bool __sane_unused__ local_only) { static const SANE_Device **devlist = 0; CANON_Device *dev; @@ -1104,7 +1104,6 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters *params) SANE_Status sane_start (SANE_Handle handle) { - int mode; char *mode_str; CANON_Scanner *s = handle; SANE_Status status; @@ -1301,33 +1300,27 @@ sane_start (SANE_Handle handle) if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_LINEART)) { - mode = 4; s->image_composition = 0; } else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_HALFTONE)) { - mode = 4; s->image_composition = 1; } else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_GRAY)) { - mode = 5; s->image_composition = 2; } else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_COLOR) || !strcmp (mode_str, SANE_I18N("Fine color"))) { - mode = 6; s->image_composition = 5; } else if (!strcmp (mode_str, SANE_I18N("Raw"))) { - mode = 6; s->image_composition = 5; } else { - mode = 6; s->image_composition = 5; } @@ -2206,8 +2199,8 @@ sane_cancel (SANE_Handle handle) /**************************************************************************/ SANE_Status -sane_set_io_mode (SANE_Handle UNUSEDARG handle, -SANE_Bool UNUSEDARG non_blocking) +sane_set_io_mode (SANE_Handle __sane_unused__ handle, +SANE_Bool __sane_unused__ non_blocking) { DBG (1, ">> sane_set_io_mode\n"); DBG (1, "<< sane_set_io_mode\n"); @@ -2217,8 +2210,8 @@ SANE_Bool UNUSEDARG non_blocking) /**************************************************************************/ SANE_Status -sane_get_select_fd (SANE_Handle UNUSEDARG handle, -SANE_Int UNUSEDARG * fd) +sane_get_select_fd (SANE_Handle __sane_unused__ handle, +SANE_Int __sane_unused__ * fd) { DBG (1, ">> sane_get_select_fd\n"); DBG (1, "<< sane_get_select_fd\n"); diff --git a/backend/canon-scsi.c b/backend/canon-scsi.c index 423a07e..a83e518 100644 --- a/backend/canon-scsi.c +++ b/backend/canon-scsi.c @@ -688,7 +688,7 @@ static SANE_Status set_parameters_fs2710 (SANE_Handle handle) { CANON_Scanner *s = handle; - int i, j, invert, shadow[4], hilite[4]; + int i, j, shadow[4], hilite[4]; double x, b, c; shadow[1] = s->ShadowR << 4; @@ -700,8 +700,6 @@ set_parameters_fs2710 (SANE_Handle handle) c = ((double) s->contrast) / 128.0; b = ((double) (s->brightness - 128)) / 128.0; - invert = strcmp (filmtype_list[1], s->val[OPT_NEGATIVE].s); - for (i = 1; i < 4; i++) { for (j = 0; j < 4096; j++) diff --git a/backend/canon.h b/backend/canon.h index 34f527b..c4dc9a8 100644 --- a/backend/canon.h +++ b/backend/canon.h @@ -46,12 +46,6 @@ #ifndef canon_h #define canon_h 1 -#ifdef __GNUC__ -#define UNUSEDARG __attribute__ ((unused)) -#else -#define UNUSEDARG -#endif - /* all the different possible model names. */ #define FB1200S "IX-12015E " #define FB620S "IX-06035E " diff --git a/backend/canon630u-common.c b/backend/canon630u-common.c index 4417141..a46424a 100644 --- a/backend/canon630u-common.c +++ b/backend/canon630u-common.c @@ -295,7 +295,7 @@ write_word (int fd, unsigned int addr, unsigned int data) /* write multiple bytes, one at a time (non-bulk) */ static SANE_Status -write_many (int fd, unsigned int addr, void *src, size_t count) +write_many (int fd, unsigned int addr, const byte *src, size_t count) { SANE_Status status; size_t i; @@ -303,8 +303,8 @@ write_many (int fd, unsigned int addr, void *src, size_t count) DBG (14, "multi write %lu\n", (u_long) count); for (i = 0; i < count; i++) { - DBG (15, " %04lx:%02x", (u_long) (addr + i), ((byte *) src)[i]); - status = write_byte (fd, addr + i, ((byte *) src)[i]); + DBG (15, " %04lx:%02x", (u_long) (addr + i), src[i]); + status = write_byte (fd, addr + i, src[i]); if (status != SANE_STATUS_GOOD) { DBG (15, "\n"); @@ -741,9 +741,9 @@ plugin_cal (CANON_Handle * s) /* parallel port setting */ write_byte (fd, PARALLEL_PORT, 0x06); - write_many (fd, 0x08, (byte *) seq002, sizeof (seq002)); + write_many (fd, 0x08, seq002, sizeof (seq002)); /* addr 0x28 isn't written */ - write_many (fd, 0x29, (byte *) seq003, sizeof (seq003)); + write_many (fd, 0x29, seq003, sizeof (seq003)); /* Verification */ buf = malloc (0x400); read_many (fd, 0x08, buf, sizeof (seq002)); diff --git a/backend/canon630u.c b/backend/canon630u.c index 6bd3431..5c1a711 100644 --- a/backend/canon630u.c +++ b/backend/canon630u.c @@ -873,7 +873,6 @@ void sane_close (SANE_Handle handle) { Canon_Scanner *prev, *scanner; - SANE_Status res; DBG (3, "sane_close\n"); @@ -906,7 +905,7 @@ sane_close (SANE_Handle handle) else first_handle = scanner->next; - res = CANON_close_device (&scanner->scan); + CANON_close_device (&scanner->scan); free (scanner); } diff --git a/backend/canon_dr.c b/backend/canon_dr.c index 381cfd6..3c058ab 100644 --- a/backend/canon_dr.c +++ b/backend/canon_dr.c @@ -3,7 +3,7 @@ This file is part of the SANE package, and implements a SANE backend for various Canon DR-series scanners. - Copyright (C) 2008-2010 m. allan noah + Copyright (C) 2008-2016 m. allan noah Yabarana Corp. www.yabarana.com provided significant funding EvriChart, Inc. www.evrichart.com provided funding and loaned equipment @@ -314,8 +314,27 @@ v50 2015-08-23, MAN - DR-C125 adds duplex padding on back side - initial support for DR-C225 - v51 2015-08-25, MAN + v51 2015-08-25, MAN (SANE 1.0.25) - DR-C125 does not invert_tly, does need sw_lut + v52 2015-11-03, MAN + - set can_color=1 by default (recent models dont have 'C' in name) + - enable jpeg for DR-6080 + - add must_downsample and must_fully_buffer + - improve dropout option handling + - add software dropout implementation for downsampled modes + v53 2015-11-06, MAN + - replace image processing methods with sanei_magic + - add swskip option + - reorder geometry group options + - use bg_color to fill missing image data + v54 2015-11-21, MAN + - br_x and br_y locked to page_width/height until changed + v55 2016-03-19, MAN + - fixed-width scanners were calculating left-side offset incorrectly in color + - initial support for DR-F120 + - rename all DUPLEX_INTERLACE_* to indicate start and end of line + v56 2016-08-23, MAN + - initial support for P-150 SANE FLOW DIAGRAM @@ -360,12 +379,13 @@ #include "../include/sane/sanei_usb.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" +#include "../include/sane/sanei_magic.h" #include "canon_dr-cmd.h" #include "canon_dr.h" #define DEBUG 1 -#define BUILD 51 +#define BUILD 56 /* values for SANE_DEBUG_CANON_DR env var: - errors 5 @@ -618,7 +638,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) global_extra_status = buf; } - /* DUPLEXOFFSET: < 1200 */ + /* DUPLEXOFFSET: < 2400 */ else if (!strncmp (lp, "duplex-offset", 13) && isspace (lp[13])) { int buf; @@ -626,9 +646,9 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) lp = sanei_config_skip_whitespace (lp); buf = atoi (lp); - if (buf > 1200) { + if (buf > 2400) { DBG (5, "sane_get_devices: config option \"duplex-offset\" " - "(%d) is > 1200, ignoring!\n", buf); + "(%d) is > 2400, ignoring!\n", buf); continue; } @@ -1262,18 +1282,21 @@ init_model (struct scanner *s) s->max_x_fb = s->max_x; s->max_y_fb = s->max_y; - /* generic settings missing from vpd */ - if (strstr (s->model_name,"C")){ - s->can_color = 1; - } + /* missing from vpd- we will unset this for b&w machines below */ + s->can_color = 1; /* specific settings missing from vpd */ - if (strstr (s->model_name,"DR-9080") - || strstr (s->model_name,"DR-7580")){ + if (strstr (s->model_name,"DR-9080")){ s->has_comp_JPEG = 1; s->rgb_format = 2; } + else if (strstr (s->model_name,"DR-6080") + || strstr (s->model_name,"DR-7580")){ + s->has_comp_JPEG = 1; + s->can_color = 0; + } + else if (strstr (s->model_name,"DR-7090")){ s->has_flatbed = 1; } @@ -1318,7 +1341,7 @@ init_model (struct scanner *s) s->color_interlace[SIDE_FRONT] = COLOR_INTERLACE_RRGGBB; s->color_interlace[SIDE_BACK] = COLOR_INTERLACE_rRgGbB; s->gray_interlace[SIDE_BACK] = GRAY_INTERLACE_gG; - s->duplex_interlace = DUPLEX_INTERLACE_FBFB; + s->duplex_interlace = DUPLEX_INTERLACE_FBfb; s->need_ccal = 1; s->need_fcal = 1; /*s->duplex_offset = 432; now set in config file*/ @@ -1398,7 +1421,7 @@ init_model (struct scanner *s) s->even_Bpl = 1; s->color_interlace[SIDE_FRONT] = COLOR_INTERLACE_RRGGBB; s->color_interlace[SIDE_BACK] = COLOR_INTERLACE_RRGGBB; - s->duplex_interlace = DUPLEX_INTERLACE_FBFB; + s->duplex_interlace = DUPLEX_INTERLACE_FBfb; s->need_fcal_buffer = 1; s->bg_color = 0x08; /*s->duplex_offset = 840; now set in config file*/ @@ -1422,6 +1445,7 @@ init_model (struct scanner *s) s->ppl_mod = 32; s->reverse_by_mode[MODE_LINEART] = 0; s->reverse_by_mode[MODE_HALFTONE] = 0; + s->can_color = 0; } else if (strstr (s->model_name,"DR-5020")){ @@ -1432,16 +1456,33 @@ init_model (struct scanner *s) s->ppl_mod = 32; s->reverse_by_mode[MODE_LINEART] = 0; s->reverse_by_mode[MODE_HALFTONE] = 0; + s->can_color = 0; + } + + /* all copied from P-215 */ + else if (strstr (s->model_name, "P-150")) { + s->color_interlace[SIDE_FRONT] = COLOR_INTERLACE_rRgGbB; + s->color_interlace[SIDE_BACK] = COLOR_INTERLACE_RRGGBB; + s->gray_interlace[SIDE_FRONT] = GRAY_INTERLACE_gG; + s->duplex_interlace = DUPLEX_INTERLACE_FBfb; + s->need_ccal = 1; + s->invert_tly = 1; + s->unknown_byte2 = 0x88; + s->rgb_format = 1; + s->has_ssm_pay_head_len = 1; + s->ppl_mod = 8; + s->ccal_version = 3; + s->can_read_sensors = 1; + s->has_card = 1; } else if (strstr (s->model_name, "P-208")) { s->color_interlace[SIDE_FRONT] = COLOR_INTERLACE_RRGGBB; s->color_interlace[SIDE_BACK] = COLOR_INTERLACE_rRgGbB; s->gray_interlace[SIDE_BACK] = GRAY_INTERLACE_gG; - s->duplex_interlace = DUPLEX_INTERLACE_FBFB; + s->duplex_interlace = DUPLEX_INTERLACE_FBfb; s->need_ccal = 1; s->invert_tly = 1; - s->can_color = 1; s->unknown_byte2 = 0x88; s->rgb_format = 1; s->has_ssm_pay_head_len = 1; @@ -1454,10 +1495,9 @@ init_model (struct scanner *s) s->color_interlace[SIDE_FRONT] = COLOR_INTERLACE_rRgGbB; s->color_interlace[SIDE_BACK] = COLOR_INTERLACE_RRGGBB; s->gray_interlace[SIDE_FRONT] = GRAY_INTERLACE_gG; - s->duplex_interlace = DUPLEX_INTERLACE_FBFB; + s->duplex_interlace = DUPLEX_INTERLACE_FBfb; s->need_ccal = 1; s->invert_tly = 1; - s->can_color = 1; s->unknown_byte2 = 0x88; s->rgb_format = 1; s->has_ssm_pay_head_len = 1; @@ -1485,7 +1525,6 @@ init_model (struct scanner *s) s->has_comp_JPEG = 1; s->rgb_format = 1; - s->can_color = 1; s->has_df_ultra = 1; s->color_inter_by_res[DPI_100] = COLOR_INTERLACE_GBR; @@ -1500,7 +1539,7 @@ init_model (struct scanner *s) s->can_write_panel = 0; s->has_ssm = 0; s->has_ssm2 = 1; - s->duplex_interlace = DUPLEX_INTERLACE_FFBB; + s->duplex_interlace = DUPLEX_INTERLACE_FfBb; s->duplex_offset_side = SIDE_FRONT; /*lies*/ @@ -1526,7 +1565,6 @@ init_model (struct scanner *s) s->has_comp_JPEG = 1; s->rgb_format = 1; - s->can_color = 1; s->has_df_ultra = 1; s->color_inter_by_res[DPI_100] = COLOR_INTERLACE_GBR; @@ -1541,7 +1579,7 @@ init_model (struct scanner *s) s->can_write_panel = 0; s->has_ssm = 0; s->has_ssm2 = 1; - s->duplex_interlace = DUPLEX_INTERLACE_FFBB; + s->duplex_interlace = DUPLEX_INTERLACE_FfBb; s->duplex_offset_side = SIDE_BACK; /*lies*/ @@ -1563,7 +1601,6 @@ init_model (struct scanner *s) s->ccal_version = 3; s->need_fcal = 1; s->sw_lut = 1; - s->can_color = 1; s->rgb_format = 1; /*s->duplex_offset = 400; now set in config file*/ @@ -1585,14 +1622,13 @@ init_model (struct scanner *s) s->color_interlace[SIDE_FRONT] = COLOR_INTERLACE_RRGGBB; s->color_interlace[SIDE_BACK] = COLOR_INTERLACE_rRgGbB; s->gray_interlace[SIDE_BACK] = GRAY_INTERLACE_gG; - s->duplex_interlace = DUPLEX_INTERLACE_FBFB; + s->duplex_interlace = DUPLEX_INTERLACE_FBfb; s->unknown_byte2 = 0x88; s->need_ccal = 1; s->ccal_version = 3; s->need_fcal = 1; s->invert_tly = 1; - s->can_color = 1; s->rgb_format = 1; /*s->duplex_offset = 400; now set in config file*/ @@ -1609,6 +1645,51 @@ init_model (struct scanner *s) s->valid_x = 8.5 * 1200; } + else if (strstr (s->model_name,"DR-F120")){ + /* TODO items: + * * has_rif = 0 ? is this correct + * * has_comp_JPEG = 0 ? is this correct + * * need_ccal = need_fcal = need_fcal_buffer = ccal_version = 0 ? is this correct + */ + + /* Required for USB coms */ + s->has_ssm = 0; + s->has_ssm2 = 1; + + /*missing*/ + s->std_res_x[DPI_100] = 1; + s->std_res_y[DPI_100] = 1; + // DPI_150 not supported + s->std_res_x[DPI_200] = 1; + s->std_res_y[DPI_200] = 1; + s->std_res_x[DPI_300] = 1; + s->std_res_y[DPI_300] = 1; + // DPI_400 not supported + s->std_res_x[DPI_600]= 1; + s->std_res_y[DPI_600] = 1; + // DPI_1200 not supported + // NOTE: This scanner supports higher resolutions + // in the Y direction, but 600 is maximum in X + + // This is true however only the ADF is ever selected in hardware + // FIXME: What extra option is needed to select this in the USB comms + s->has_flatbed = 1; + + /* duplex */ + s->duplex_interlace = DUPLEX_INTERLACE_fFBb; + s->color_interlace[SIDE_FRONT] = COLOR_INTERLACE_GBR; + s->color_interlace[SIDE_BACK] = COLOR_INTERLACE_GBR; + s->color_inter_by_res[DPI_100] = COLOR_INTERLACE_RGB; + s->color_inter_by_res[DPI_600] = COLOR_INTERLACE_RGB; + s->duplex_offset_side = SIDE_BACK; + + /* weirdness */ + s->fixed_width = 1; + + /* lies */ + s->can_halftone = 0; + } + DBG (10, "init_model: finish\n"); return SANE_STATUS_GOOD; @@ -2239,7 +2320,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if (i > 1){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if (s->u.mode != MODE_COLOR && s->u.mode != MODE_GRAYSCALE){ + if ( must_downsample(s) || s->s.mode < MODE_GRAYSCALE ){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -2361,6 +2442,24 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) opt->cap = SANE_CAP_INACTIVE; } + /* Software blank page skip */ + if(option==OPT_SWSKIP){ + + opt->name = "swskip"; + opt->title = SANE_I18N ("Software blank skip percentage"); + opt->desc = SANE_I18N("Request driver to discard pages with low percentage of dark pixels"); + opt->type = SANE_TYPE_FIXED; + opt->unit = SANE_UNIT_PERCENT; + opt->constraint_type = SANE_CONSTRAINT_RANGE; + opt->constraint.range = &s->swskip_range; + + s->swskip_range.quant=SANE_FIX(0.10001); + s->swskip_range.min=SANE_FIX(0); + s->swskip_range.max=SANE_FIX(100); + + opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; + } + /*staple detection*/ if(option==OPT_STAPLEDETECT){ opt->name = "stapledetect"; @@ -2751,12 +2850,16 @@ sane_control_option (SANE_Handle handle, SANE_Int option, *val_p = s->swcrop; return SANE_STATUS_GOOD; + case OPT_SWSKIP: + *val_p = SANE_FIX(s->swskip); + return SANE_STATUS_GOOD; + case OPT_STAPLEDETECT: *val_p = s->stapledetect; return SANE_STATUS_GOOD; case OPT_DROPOUT_COLOR_F: - switch (s->dropout_color_f) { + switch (s->dropout_color[SIDE_FRONT]) { case COLOR_NONE: strcpy (val, STRING_NONE); break; @@ -2782,7 +2885,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, return SANE_STATUS_GOOD; case OPT_DROPOUT_COLOR_B: - switch (s->dropout_color_b) { + switch (s->dropout_color[SIDE_BACK]) { case COLOR_NONE: strcpy (val, STRING_NONE); break; @@ -3003,6 +3106,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (s->u.page_x == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; + /* if full width image, and paper size is changed, + change the image size to match new paper */ + if (s->u.tl_x == 0 && s->u.br_x == s->u.page_x){ + DBG (20, "sane_control_option: br_x tracking page_width\n"); + s->u.br_x = FIXED_MM_TO_SCANNER_UNIT(val_c); + *info |= SANE_INFO_RELOAD_PARAMS; + } + s->u.page_x = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_OPTIONS; @@ -3012,6 +3123,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (s->u.page_y == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; + /* if full height image, and paper size is changed, + change the image size to match new paper */ + if (s->u.tl_y == 0 && s->u.br_y == s->u.page_y){ + DBG (20, "sane_control_option: br_y tracking page_height\n"); + s->u.br_y = FIXED_MM_TO_SCANNER_UNIT(val_c); + *info |= SANE_INFO_RELOAD_PARAMS; + } + s->u.page_y = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_OPTIONS; @@ -3072,42 +3191,46 @@ sane_control_option (SANE_Handle handle, SANE_Int option, s->swcrop = val_c; return SANE_STATUS_GOOD; + case OPT_SWSKIP: + s->swskip = SANE_UNFIX(val_c); + return SANE_STATUS_GOOD; + case OPT_STAPLEDETECT: s->stapledetect = val_c; return SANE_STATUS_GOOD; case OPT_DROPOUT_COLOR_F: if (!strcmp(val, STRING_NONE)) - s->dropout_color_f = COLOR_NONE; + s->dropout_color[SIDE_FRONT] = COLOR_NONE; else if (!strcmp(val, STRING_RED)) - s->dropout_color_f = COLOR_RED; + s->dropout_color[SIDE_FRONT] = COLOR_RED; else if (!strcmp(val, STRING_GREEN)) - s->dropout_color_f = COLOR_GREEN; + s->dropout_color[SIDE_FRONT] = COLOR_GREEN; else if (!strcmp(val, STRING_BLUE)) - s->dropout_color_f = COLOR_BLUE; + s->dropout_color[SIDE_FRONT] = COLOR_BLUE; else if (!strcmp(val, STRING_EN_RED)) - s->dropout_color_f = COLOR_EN_RED; + s->dropout_color[SIDE_FRONT] = COLOR_EN_RED; else if (!strcmp(val, STRING_EN_GREEN)) - s->dropout_color_f = COLOR_EN_GREEN; + s->dropout_color[SIDE_FRONT] = COLOR_EN_GREEN; else if (!strcmp(val, STRING_EN_BLUE)) - s->dropout_color_f = COLOR_EN_BLUE; + s->dropout_color[SIDE_FRONT] = COLOR_EN_BLUE; return SANE_STATUS_GOOD; case OPT_DROPOUT_COLOR_B: if (!strcmp(val, STRING_NONE)) - s->dropout_color_b = COLOR_NONE; + s->dropout_color[SIDE_BACK] = COLOR_NONE; else if (!strcmp(val, STRING_RED)) - s->dropout_color_b = COLOR_RED; + s->dropout_color[SIDE_BACK] = COLOR_RED; else if (!strcmp(val, STRING_GREEN)) - s->dropout_color_b = COLOR_GREEN; + s->dropout_color[SIDE_BACK] = COLOR_GREEN; else if (!strcmp(val, STRING_BLUE)) - s->dropout_color_b = COLOR_BLUE; + s->dropout_color[SIDE_BACK] = COLOR_BLUE; else if (!strcmp(val, STRING_EN_RED)) - s->dropout_color_b = COLOR_EN_RED; + s->dropout_color[SIDE_BACK] = COLOR_EN_RED; else if (!strcmp(val, STRING_EN_GREEN)) - s->dropout_color_b = COLOR_EN_GREEN; + s->dropout_color[SIDE_BACK] = COLOR_EN_GREEN; else if (!strcmp(val, STRING_EN_BLUE)) - s->dropout_color_b = COLOR_EN_BLUE; + s->dropout_color[SIDE_BACK] = COLOR_EN_BLUE; return SANE_STATUS_GOOD; case OPT_BUFFERMODE: @@ -3344,6 +3467,11 @@ ssm_do (struct scanner *s) return ret; } + if(s->s.mode == MODE_COLOR){ + DBG (10, "ssm_do: unneeded, finishing\n"); + return ret; + } + if(s->has_ssm){ unsigned char cmd[SET_SCAN_MODE_len]; @@ -3366,7 +3494,7 @@ ssm_do (struct scanner *s) set_SSM_DO_unk1(out, 0x03); - switch(s->dropout_color_f){ + switch(s->dropout_color[SIDE_FRONT]){ case COLOR_RED: set_SSM_DO_unk2(out, 0x05); set_SSM_DO_f_do(out,SSM_DO_red); @@ -3393,7 +3521,7 @@ ssm_do (struct scanner *s) break; } - switch(s->dropout_color_b){ + switch(s->dropout_color[SIDE_BACK]){ case COLOR_RED: set_SSM_DO_unk2(out, 0x05); set_SSM_DO_b_do(out,SSM_DO_red); @@ -3444,7 +3572,7 @@ ssm_do (struct scanner *s) memset(out,0,outLen); - switch(s->dropout_color_f){ + switch(s->dropout_color[SIDE_FRONT]){ case COLOR_RED: set_SSM2_DO_do(out,SSM_DO_red); break; @@ -4138,9 +4266,7 @@ sane_start (SANE_Handle handle) * tell the user the size of the image. the sane * API has no way to inform the frontend of this, * so we block and buffer. yuck */ - if( (s->swdeskew || s->swdespeck || s->swcrop) - && s->s.format != SANE_FRAME_JPEG - ){ + if(must_fully_buffer(s)){ /* get image */ while(!s->s.eof[s->side] && !ret){ @@ -4166,7 +4292,16 @@ sane_start (SANE_Handle handle) if(s->swdespeck){ buffer_despeck(s,s->side); } - + if(s->swskip){ + /* Skipping means throwing out this image. + * Pretend the user read the whole thing + * and call sane_start again. + * This assumes we are running in batch mode. */ + if(buffer_isblank(s,s->side)){ + s->u.eof[s->side] = 1; + return sane_start(handle); + } + } } ret = check_for_cancel(s); @@ -4752,23 +4887,7 @@ read_from_scanner(struct scanner *s, int side, int exact) /* this is non-jpeg data, fill remainder, change rx'd size */ else{ - - DBG (15, "read_from_scanner: eof: %d %d\n", s->i.bytes_tot[side], s->i.bytes_sent[side]); - - /* clone the last line repeatedly until the end */ - while(s->i.bytes_tot[side] > s->i.bytes_sent[side]){ - memcpy( - s->buffers[side]+s->i.bytes_sent[side]-s->i.Bpl, - s->buffers[side]+s->i.bytes_sent[side], - s->i.Bpl - ); - s->i.bytes_sent[side] += s->i.Bpl; - } - - DBG (15, "read_from_scanner: eof2: %d %d\n", s->i.bytes_tot[side], s->i.bytes_sent[side]); - - /* pretend we got all the data from scanner */ - s->s.bytes_sent[side] = s->s.bytes_tot[side]; + fill_image(s,side); } s->i.eof[side] = 1; @@ -4890,40 +5009,8 @@ read_from_scanner_duplex(struct scanner *s,int exact) /* this is non-jpeg data, fill remainder, change rx'd size */ else{ - - DBG (15, "read_from_scanner_duplex: eof: %d %d %d %d\n", - s->i.bytes_tot[SIDE_FRONT], s->i.bytes_sent[SIDE_FRONT], - s->i.bytes_tot[SIDE_BACK], s->i.bytes_sent[SIDE_BACK] - ); - - /* clone the last line repeatedly until the end */ - while(s->i.bytes_tot[SIDE_FRONT] > s->i.bytes_sent[SIDE_FRONT]){ - memcpy( - s->buffers[SIDE_FRONT]+s->i.bytes_sent[SIDE_FRONT]-s->i.Bpl, - s->buffers[SIDE_FRONT]+s->i.bytes_sent[SIDE_FRONT], - s->i.Bpl - ); - s->i.bytes_sent[SIDE_FRONT] += s->i.Bpl; - } - - /* clone the last line repeatedly until the end */ - while(s->i.bytes_tot[SIDE_BACK] > s->i.bytes_sent[SIDE_BACK]){ - memcpy( - s->buffers[SIDE_BACK]+s->i.bytes_sent[SIDE_BACK]-s->i.Bpl, - s->buffers[SIDE_BACK]+s->i.bytes_sent[SIDE_BACK], - s->i.Bpl - ); - s->i.bytes_sent[SIDE_BACK] += s->i.Bpl; - } - - DBG (15, "read_from_scanner_duplex: eof2: %d %d %d %d\n", - s->i.bytes_tot[SIDE_FRONT], s->i.bytes_sent[SIDE_FRONT], - s->i.bytes_tot[SIDE_BACK], s->i.bytes_sent[SIDE_BACK] - ); - - /* pretend we got all the data from scanner */ - s->s.bytes_sent[SIDE_FRONT] = s->s.bytes_tot[SIDE_FRONT]; - s->s.bytes_sent[SIDE_BACK] = s->s.bytes_tot[SIDE_BACK]; + fill_image(s,SIDE_FRONT); + fill_image(s,SIDE_BACK); } s->i.eof[SIDE_FRONT] = 1; @@ -5222,16 +5309,20 @@ copy_duplex(struct scanner *s, unsigned char * buf, int len) } /* full line of front, then full line of back */ - else if(s->duplex_interlace == DUPLEX_INTERLACE_FFBB){ + else if(s->duplex_interlace == DUPLEX_INTERLACE_FfBb || s->duplex_interlace == DUPLEX_INTERLACE_fFBb){ for(i=0; iduplex_interlace == DUPLEX_INTERLACE_FfBb){ + memcpy(front+flen,buf+i,bwidth); + }else{ + rmemcpy(front+flen,buf+i,bwidth,3); // only 24bit color is supported + } flen+=bwidth; memcpy(back+blen,buf+i+bwidth,bwidth); blen+=bwidth; } } - /*just alternating bytes, FBFBFB*/ + /*just alternating bytes, FBfb*/ else { for(i=0; is.mode) { case MODE_COLOR: - memcpy(line, buff, sbwidth); + if(must_downsample(s) && s->dropout_color[side]){ + switch(s->dropout_color[side]){ + case COLOR_RED: + for(i=0;ii.mode) { case MODE_COLOR: - memcpy(s->buffers[side]+s->i.bytes_sent[side], line+offset, ibwidth); + memcpy(s->buffers[side]+s->i.bytes_sent[side], line+(offset*3), ibwidth); s->i.bytes_sent[side] += ibwidth; break; @@ -5410,6 +5556,43 @@ read_from_buffer(struct scanner *s, SANE_Byte * buf, SANE_Int max_len, return ret; } +/* fill remainder of buffer with background if scanner stops early */ +static SANE_Status +fill_image(struct scanner *s,int side) +{ + SANE_Status ret=SANE_STATUS_GOOD; + + unsigned char bg_color = calc_bg_color(s); + int fill_bytes = s->i.bytes_tot[side]-s->i.bytes_sent[side]; + + if(!fill_bytes){ + return ret; + } + + DBG (15, "fill_image: side:%d bytes:%d bg_color:%02x\n", side, fill_bytes, bg_color); + + /* fill the rest with bg_color */ + memset(s->buffers[side]+s->i.bytes_sent[side],bg_color,fill_bytes); + + /* pretend we got all the data from scanner */ + s->i.bytes_sent[side] = s->i.bytes_tot[side]; + s->s.bytes_sent[side] = s->s.bytes_tot[side]; + + return ret; +} + +/* return the bg color based on scanner settings */ +static unsigned char +calc_bg_color(struct scanner *s) +{ + unsigned char bg_color = s->lut[s->bg_color]; + + if(s->u.mode <= MODE_HALFTONE) + bg_color = (bg_colorthreshold)?0xff:0x00; + + return bg_color; +} + /* * @@ Section 5 - calibration functions */ @@ -7144,18 +7327,20 @@ wait_scanner(struct scanner *s) NULL, 0, NULL, NULL ); - + + // some scanners (such as DR-F120) are OK but will not respond to commands + // when in sleep mode. By checking the sense it wakes them up. if (ret != SANE_STATUS_GOOD) { - DBG(5,"WARNING: Brain-dead scanner. Hitting with stick\n"); + DBG(5,"WARNING: Brain-dead scanner. Hitting with request sense.\n"); ret = do_cmd ( - s, 0, 1, + s, 1, 1, cmd, cmdLen, NULL, 0, NULL, NULL ); } if (ret != SANE_STATUS_GOOD) { - DBG(5,"WARNING: Brain-dead scanner. Hitting with stick again\n"); + DBG(5,"WARNING: Brain-dead scanner. Hitting with stick instead.\n"); ret = do_cmd ( s, 0, 1, cmd, cmdLen, @@ -7168,7 +7353,7 @@ wait_scanner(struct scanner *s) DBG (5, "wait_scanner: error '%s'\n", sane_strstatus (ret)); } - DBG (10, "wait_scanner: finish\n"); + DBG (10, "wait_scanner: finish (status=%d)\n", ret); return ret; } @@ -7350,102 +7535,40 @@ buffer_deskew(struct scanner *s, int side) { SANE_Status ret = SANE_STATUS_GOOD; - int pwidth = s->i.width; - int width = s->i.Bpl; - int height = s->i.height; - - double TSlope = 0; - int TXInter = 0; - int TYInter = 0; - double TSlopeHalf = 0; - int TOffsetHalf = 0; - - double LSlope = 0; - int LXInter = 0; - int LYInter = 0; - double LSlopeHalf = 0; - int LOffsetHalf = 0; - - int rotateX = 0; - int rotateY = 0; - - int * topBuf = NULL, * botBuf = NULL; + unsigned char bg_color = calc_bg_color(s); DBG (10, "buffer_deskew: start\n"); - /* get buffers for edge detection */ - topBuf = getTransitionsY(s,side,1); - if(!topBuf){ - DBG (5, "buffer_deskew: cant gTY\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } - - if(0){ - int i; - for(i=0;i=0 && topBuf[i] < height) - s->buffers[side][topBuf[i]*width+i] = 0; - } - } + ret = sane_get_parameters((SANE_Handle) s, &s->s_params); - botBuf = getTransitionsY(s,side,0); - if(!botBuf){ - DBG (5, "buffer_deskew: cant gTY\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } + /*only find skew on first image from a page, or if first image had error */ + if(s->side == SIDE_FRONT || s->u.source == SOURCE_ADF_BACK || s->deskew_stat){ - /* find best top line */ - ret = getEdgeIterate (pwidth, height, s->i.dpi_y, topBuf, - &TSlope, &TXInter, &TYInter); - if(ret){ - DBG(5,"buffer_deskew: gEI error: %d",ret); - goto cleanup; - } - DBG(15,"top: %04.04f %d %d\n",TSlope,TXInter,TYInter); + s->deskew_stat = sanei_magic_findSkew( + &s->s_params,s->buffers[side],s->u.dpi_x,s->u.dpi_y, + &s->deskew_vals[0],&s->deskew_vals[1],&s->deskew_slope); - /* slope is too shallow, don't want to divide by 0 */ - if(fabs(TSlope) < 0.0001){ - DBG(15,"buffer_deskew: slope too shallow: %0.08f\n",TSlope); - goto cleanup; + if(s->deskew_stat){ + DBG (5, "buffer_deskew: bad findSkew, bailing\n"); + goto cleanup; + } } - - /* find best left line, perpendicular to top line */ - LSlope = (double)-1/TSlope; - ret = getEdgeSlope (pwidth, height, topBuf, botBuf, LSlope, - &LXInter, &LYInter); - if(ret){ - DBG(5,"buffer_deskew: gES error: %d",ret); - goto cleanup; + /* backside images can use a 'flipped' version of frontside data */ + else{ + s->deskew_slope *= -1; + s->deskew_vals[0] = s->s_params.pixels_per_line - s->deskew_vals[0]; } - DBG(15,"buffer_deskew: left: %04.04f %d %d\n",LSlope,LXInter,LYInter); - - /* find point about which to rotate */ - TSlopeHalf = tan(atan(TSlope)/2); - TOffsetHalf = LYInter; - DBG(15,"buffer_deskew: top half: %04.04f %d\n",TSlopeHalf,TOffsetHalf); - - LSlopeHalf = tan((atan(LSlope) + ((LSlope < 0)?-M_PI_2:M_PI_2))/2); - LOffsetHalf = - LSlopeHalf * TXInter; - DBG(15,"buffer_deskew: left half: %04.04f %d\n",LSlopeHalf,LOffsetHalf); - rotateX = (LOffsetHalf-TOffsetHalf) / (TSlopeHalf-LSlopeHalf); - rotateY = TSlopeHalf * rotateX + TOffsetHalf; - DBG(15,"buffer_deskew: rotate: %d %d\n",rotateX,rotateY); + ret = sanei_magic_rotate(&s->s_params,s->buffers[side], + s->deskew_vals[0],s->deskew_vals[1],s->deskew_slope,bg_color); - ret = rotateOnCenter (s, side, rotateX, rotateY, TSlope); if(ret){ - DBG(5,"buffer_deskew: gES error: %d",ret); + DBG(5,"buffer_deskew: rotate error: %d",ret); + ret = SANE_STATUS_GOOD; goto cleanup; } cleanup: - if(topBuf) - free(topBuf); - if(botBuf) - free(botBuf); - DBG (10, "buffer_deskew: finish\n"); return ret; } @@ -7458,173 +7581,50 @@ buffer_crop(struct scanner *s, int side) { SANE_Status ret = SANE_STATUS_GOOD; - int bwidth = s->i.Bpl; - int width = s->i.width; - int height = s->i.height; - - int top = 0; - int bot = 0; - int left = width; - int right = 0; - - int * topBuf = NULL, * botBuf = NULL; - int * leftBuf = NULL, * rightBuf = NULL; - int leftCount = 0, rightCount = 0, botCount = 0; - int i; - DBG (10, "buffer_crop: start\n"); - /* get buffers to find sides and bottom */ - topBuf = getTransitionsY(s,side,1); - if(!topBuf){ - DBG (5, "buffer_crop: no topBuf\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } - - botBuf = getTransitionsY(s,side,0); - if(!botBuf){ - DBG (5, "buffer_crop: no botBuf\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } + ret = sane_get_parameters((SANE_Handle) s, &s->s_params); - leftBuf = getTransitionsX(s,side,1); - if(!leftBuf){ - DBG (5, "buffer_crop: no leftBuf\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } + ret = sanei_magic_findEdges( + &s->s_params,s->buffers[side],s->u.dpi_x,s->u.dpi_y, + &s->crop_vals[0],&s->crop_vals[1],&s->crop_vals[2],&s->crop_vals[3]); - rightBuf = getTransitionsX(s,side,0); - if(!rightBuf){ - DBG (5, "buffer_crop: no rightBuf\n"); - ret = SANE_STATUS_NO_MEM; + if(ret){ + DBG (5, "buffer_crop: bad edges, bailing\n"); + ret = SANE_STATUS_GOOD; goto cleanup; } - /* loop thru top and bottom lists, look for l and r extremes */ - for(i=0; i topBuf[i]){ - if(left > i){ - left = i; - } - - leftCount++; - if(leftCount > 3){ - break; - } - } - else{ - leftCount = 0; - left = width; - } - } - - for(i=width-1; i>=0; i--){ - if(botBuf[i] > topBuf[i]){ - if(right < i){ - right = i; - } - - rightCount++; - if(rightCount > 3){ - break; - } - } - else{ - rightCount = 0; - right = -1; - } - } - - /* loop thru left and right lists, look for bottom extreme */ - for(i=height-1; i>=0; i--){ - if(rightBuf[i] > leftBuf[i]){ - if(bot < i){ - bot = i; - } + DBG (15, "buffer_crop: t:%d b:%d l:%d r:%d\n", + s->crop_vals[0],s->crop_vals[1],s->crop_vals[2],s->crop_vals[3]); - botCount++; - if(botCount > 3){ - break; - } - } - else{ - botCount = 0; - bot = -1; - } + /* if we will later binarize this image, make sure the width + * is a multiple of 8 pixels, by adjusting the right side */ + if ( must_downsample(s) && s->u.mode < MODE_GRAYSCALE ){ + s->crop_vals[3] -= (s->crop_vals[3]-s->crop_vals[2]) % 8; } - DBG (15, "buffer_crop: t:%d b:%d l:%d r:%d\n",top,bot,left,right); - /* now crop the image */ - /*FIXME: crop duplex backside at same time?*/ - if(left < right && top < bot){ - - int pixels = 0; - int bytes = 0; - unsigned char * line = NULL; - - /*convert left and right to bytes, figure new byte and pixel width */ - switch (s->i.mode) { - - case MODE_COLOR: - pixels = right-left; - bytes = pixels * 3; - left *= 3; - right *= 3; - break; - - case MODE_GRAYSCALE: - pixels = right-left; - bytes = right-left; - break; - - case MODE_LINEART: - case MODE_HALFTONE: - left /= 8; - right = (right+7)/8; - bytes = right-left; - pixels = bytes * 8; - break; - } - - DBG (15, "buffer_crop: l:%d r:%d p:%d b:%d\n",left,right,pixels,bytes); - - line = malloc(bytes); - if(!line){ - DBG (5, "buffer_crop: no line\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } - - s->i.bytes_sent[side] = 0; - - for(i=top; ibuffers[side] + i*bwidth + left, bytes); - memcpy(s->buffers[side] + s->i.bytes_sent[side], line, bytes); - s->i.bytes_sent[side] += bytes; - } + ret = sanei_magic_crop(&s->s_params,s->buffers[side], + s->crop_vals[0],s->crop_vals[1],s->crop_vals[2],s->crop_vals[3]); - s->i.bytes_tot[side] = s->i.bytes_sent[side]; - s->i.width = pixels; - s->i.height = bot-top; - s->i.Bpl = bytes; - - free(line); + if(ret){ + DBG (5, "buffer_crop: bad crop, bailing\n"); + ret = SANE_STATUS_GOOD; + goto cleanup; } - cleanup: - if(topBuf) - free(topBuf); - if(botBuf) - free(botBuf); - if(leftBuf) - free(leftBuf); - if(rightBuf) - free(rightBuf); - + /* need to update user with new size */ + s->i.width = s->s_params.pixels_per_line; + s->i.height = s->s_params.lines; + s->i.Bpl = s->s_params.bytes_per_line; + + /* update image size counter to new, smaller size */ + s->i.bytes_tot[side] = s->s_params.lines * s->s_params.bytes_per_line; + s->i.bytes_sent[side] = s->i.bytes_tot[side]; + s->u.bytes_sent[side] = 0; + + cleanup: DBG (10, "buffer_crop: finish\n"); return ret; } @@ -7636,938 +7636,77 @@ static SANE_Status buffer_despeck(struct scanner *s, int side) { SANE_Status ret = SANE_STATUS_GOOD; - int i,j,k,l,n; - int w = s->i.Bpl; - int pw = s->i.width; - int h = s->i.height; - int t = w*h; - int d = s->swdespeck; DBG (10, "buffer_despeck: start\n"); - switch (s->i.mode){ + ret = sane_get_parameters((SANE_Handle) s, &s->s_params); - case MODE_COLOR: - for(i=w; ibuffers[side][i + j*3 + k*w + l*3 + n]; - } - - if(tmp < thresh) - thresh = tmp; - } - } + ret = sanei_magic_despeck(&s->s_params,s->buffers[side],s->swdespeck); + if(ret){ + DBG (5, "buffer_despeck: bad despeck, bailing\n"); + ret = SANE_STATUS_GOOD; + goto cleanup; + } - thresh = (thresh + 255*3 + 255*3)/3; - - /*loop over rows and columns around window */ - for(k=-1; kbuffers[side][i + j*3 + k*w + l*3 + n]; - outer[n] += tmp[n]; - } - if(tmp[0]+tmp[1]+tmp[2] < thresh){ - hits++; - break; - } - } - } +/* Look if image has too few dark pixels.*/ +static int +buffer_isblank(struct scanner *s, int side) +{ + SANE_Status ret = SANE_STATUS_GOOD; + int status = 0; - for(n=0; n<3; n++){ - outer[n] /= (4*d + 4); - } + DBG (10, "buffer_isblank: start\n"); - /*no hits, overwrite with avg surrounding color*/ - if(!hits){ - for(k=0; kbuffers[side][i + j*3 + k*w + l*3 + n] = outer[n]; - } - } - } - } + ret = sane_get_parameters((SANE_Handle) s, &s->s_params); - } - } - break; + ret = sanei_magic_isBlank2(&s->s_params, s->buffers[side], + s->u.dpi_x, s->u.dpi_y, s->swskip); - case MODE_GRAYSCALE: - for(i=w; ibuffers[side][i + j + k*w + l] < thresh) - thresh = s->buffers[side][i + j + k*w + l]; - } - } +/* certain options require the entire image to + * be collected from the scanner before we can + * tell the user the size of the image. */ +static int +must_fully_buffer(struct scanner *s) +{ - thresh = (thresh + 255 + 255)/3; - - /*loop over rows and columns around window */ - for(k=-1; kswdeskew || s->swdespeck || s->swcrop) + && s->s.format != SANE_FRAME_JPEG + ){ + return 1; + } - int tmp = 0; + return 0; +} - /* dont count pixels in the window */ - if(k != -1 && k != d && l != -1 && l != d) - continue; - - tmp = s->buffers[side][i + j + k*w + l]; - - if(tmp < thresh){ - hits++; - break; - } - - outer += tmp; - } - } - - outer /= (4*d + 4); - - /*no hits, overwrite with avg surrounding color*/ - if(!hits){ - for(k=0; kbuffers[side][i + j + k*w + l] = outer; - } - } - } - - } - } - break; - - case MODE_LINEART: - case MODE_HALFTONE: - for(i=w; ibuffers[side][i + k*w + (j+l)/8] >> (7-(j+l)%8) & 1; - } - } - - if(!curr) - continue; - - /*loop over rows and columns around window */ - for(k=-1; kbuffers[side][i + k*w + (j+l)/8] >> (7-(j+l)%8) & 1; - - if(hits) - break; - } - } - - /*no hits, overwrite with white*/ - if(!hits){ - for(k=0; kbuffers[side][i + k*w + (j+l)/8] &= ~(1 << (7-(j+l)%8)); - } - } - } - - } - } - break; - - default: - break; - } - - DBG (10, "buffer_despeck: finish\n"); - return ret; -} - -/* Loop thru the image width and look for first color change in each column. - * Return a malloc'd array. Caller is responsible for freeing. */ -int * -getTransitionsY (struct scanner *s, int side, int top) -{ - int * buff; - - int i, j, k; - int near, far; - int winLen = 9; - - int width = s->i.width; - int height = s->i.height; - int depth = 1; - - /* defaults for bottom-up */ - int firstLine = height-1; - int lastLine = -1; - int direction = -1; - - DBG (10, "getTransitionsY: start\n"); - - buff = calloc(width,sizeof(int)); - if(!buff){ - DBG (5, "getTransitionsY: no buff\n"); - return NULL; - } - - /* override for top-down */ - if(top){ - firstLine = 0; - lastLine = height; - direction = 1; - } - - /* load the buff array with y value for first color change from edge - * gray/color uses a different algo from binary/halftone */ - switch (s->i.mode) { - - case MODE_COLOR: - depth = 3; - - case MODE_GRAYSCALE: - - for(i=0; ibuffers[side][(firstLine*width+i) * depth + k]; - } - near *= winLen; - far = near; - - /* move windows, check delta */ - for(j=firstLine+direction; j!=lastLine; j+=direction){ - - int farLine = j-winLen*2*direction; - int nearLine = j-winLen*direction; - - if(farLine < 0 || farLine >= height){ - farLine = firstLine; - } - if(nearLine < 0 || nearLine >= height){ - nearLine = firstLine; - } - - for(k=0; kbuffers[side][(farLine*width+i)*depth+k]; - far += s->buffers[side][(nearLine*width+i)*depth+k]; - - near -= s->buffers[side][(nearLine*width+i)*depth+k]; - near += s->buffers[side][(j*width+i)*depth+k]; - } - - if(abs(near - far) > winLen*depth*9){ - buff[i] = j; - break; - } - } - } - break; - - case MODE_LINEART: - case MODE_HALFTONE: - for(i=0; ibuffers[side][(firstLine*width+i)/8] >> (7-(i%8)) & 1; - - /* move */ - for(j=firstLine+direction; j!=lastLine; j+=direction){ - if((s->buffers[side][(j*width+i)/8] >> (7-(i%8)) & 1) != near){ - buff[i] = j; - break; - } - } - } - break; - - } - - /* blast any stragglers with no neighbors within .5 inch */ - for(i=0;ii.dpi_y/2) - sum++; - } - if(sum < 2) - buff[i] = lastLine; - } - - DBG (10, "getTransitionsY: finish\n"); - - return buff; -} - -/* Loop thru the image height and look for first color change in each row. - * Return a malloc'd array. Caller is responsible for freeing. */ -int * -getTransitionsX (struct scanner *s, int side, int left) -{ - int * buff; - - int i, j, k; - int near, far; - int winLen = 9; - - int bwidth = s->i.Bpl; - int width = s->i.width; - int height = s->i.height; - int depth = 1; - - /* defaults for right-first */ - int firstCol = width-1; - int lastCol = -1; - int direction = -1; - - DBG (10, "getTransitionsX: start\n"); - - buff = calloc(height,sizeof(int)); - if(!buff){ - DBG (5, "getTransitionsY: no buff\n"); - return NULL; - } - - /* override for left-first*/ - if(left){ - firstCol = 0; - lastCol = width; - direction = 1; - } - - /* load the buff array with x value for first color change from edge - * gray/color uses a different algo from binary/halftone */ - switch (s->i.mode) { - - case MODE_COLOR: - depth = 3; - - case MODE_GRAYSCALE: - - for(i=0; ibuffers[side][i*bwidth + k]; - } - near *= winLen; - far = near; - - /* move windows, check delta */ - for(j=firstCol+direction; j!=lastCol; j+=direction){ - - int farCol = j-winLen*2*direction; - int nearCol = j-winLen*direction; - - if(farCol < 0 || farCol >= width){ - farCol = firstCol; - } - if(nearCol < 0 || nearCol >= width){ - nearCol = firstCol; - } - - for(k=0; kbuffers[side][i*bwidth + farCol*depth + k]; - far += s->buffers[side][i*bwidth + nearCol*depth + k]; - - near -= s->buffers[side][i*bwidth + nearCol*depth + k]; - near += s->buffers[side][i*bwidth + j*depth + k]; - } - - if(abs(near - far) > winLen*depth*9){ - buff[i] = j; - break; - } - } - } - break; - - case MODE_LINEART: - case MODE_HALFTONE: - for(i=0; ibuffers[side][i*bwidth + firstCol/8] >> (7-(firstCol%8)) & 1; - - /* move */ - for(j=firstCol+direction; j!=lastCol; j+=direction){ - if((s->buffers[side][i*bwidth + j/8] >> (7-(j%8)) & 1) != near){ - buff[i] = j; - break; - } - } - } - break; - - } - - /* blast any stragglers with no neighbors within .5 inch */ - for(i=0;ii.dpi_x/2) - sum++; - } - if(sum < 2) - buff[i] = lastCol; - } - - DBG (10, "getTransitionsX: finish\n"); - - return buff; -} - -/* Loop thru a getTransitions array, and use a simplified Hough transform - * to divide likely edges into a 2-d array of bins. Then weight each - * bin based on its angle and offset. Return the 'best' bin. */ -static SANE_Status -getLine (int height, int width, int * buff, - int slopes, double minSlope, double maxSlope, - int offsets, int minOffset, int maxOffset, - double * finSlope, int * finOffset, int * finDensity) -{ - SANE_Status ret = 0; - - int ** lines = NULL; - int i, j; - int rise, run; - double slope; - int offset; - int sIndex, oIndex; - int hWidth = width/2; - - double * slopeCenter = NULL; - int * slopeScale = NULL; - double * offsetCenter = NULL; - int * offsetScale = NULL; - - int maxDensity = 1; - double absMaxSlope = fabs(maxSlope); - double absMinSlope = fabs(minSlope); - int absMaxOffset = abs(maxOffset); - int absMinOffset = abs(minOffset); - - DBG(10,"getLine: start %+0.4f %+0.4f %d %d\n", - minSlope,maxSlope,minOffset,maxOffset); - - /*silence compiler*/ - height = height; - - if(absMaxSlope < absMinSlope) - absMaxSlope = absMinSlope; - - if(absMaxOffset < absMinOffset) - absMaxOffset = absMinOffset; - - /* build an array of pretty-print values for slope */ - slopeCenter = calloc(slopes,sizeof(double)); - if(!slopeCenter){ - DBG(5,"getLine: cant load slopeCenter\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } - - /* build an array of scaling factors for slope */ - slopeScale = calloc(slopes,sizeof(int)); - if(!slopeScale){ - DBG(5,"getLine: cant load slopeScale\n"); - ret = SANE_STATUS_NO_MEM; - goto cleanup; - } - - for(j=0;j= maxSlope || slope < minSlope) - continue; - - /* offset in center of width, not y intercept! */ - offset = slope * hWidth + buff[i] - slope * i; - if(offset >= maxOffset || offset < minOffset) - continue; - - sIndex = (slope - minSlope) * slopes/(maxSlope-minSlope); - if(sIndex >= slopes) - continue; - - oIndex = (offset - minOffset) * offsets/(maxOffset-minOffset); - if(oIndex >= offsets) - continue; - - lines[sIndex][oIndex]++; - } - } - - /* go thru array, and find most dense line (highest number) */ - for(i=0;i maxDensity) - maxDensity = lines[i][j]; - } - } - - DBG(15,"getLine: maxDensity %d\n",maxDensity); - - *finSlope = 0; - *finOffset = 0; - *finDensity = 0; - - /* go thru array, and scale densities to % of maximum, plus adjust for - * prefered (smaller absolute value) slope and offset */ - for(i=0;i *finDensity){ - *finDensity = lines[i][j]; - *finSlope = slopeCenter[i]; - *finOffset = offsetCenter[j]; - } - } - } - - if(0){ - DBG(15,"offsetCenter: "); - for(j=0;j topDensity){ - topSlope = slope; - topOffset = offset; - topDensity = density; - } - } - } - - DBG(15,"getEdgeIterate: ok %+0.4f %d %d\n",topSlope,topOffset,topDensity); - - /* did not find anything promising on first pass, - * give up instead of fixating on some small, pointless feature */ - if(pass == 1 && topDensity < width/5){ - DBG(5,"getEdgeIterate: density too small %d %d\n",topDensity,width); - topOffset = 0; - topSlope = 0; - break; - } - - /* if slope can zoom in some more, do so. */ - if(sStep >= 0.0001){ - minSlope = topSlope - sStep; - maxSlope = topSlope + sStep; - go = 1; - } - - /* if offset can zoom in some more, do so. */ - if(oStep){ - minOffset = topOffset - oStep; - maxOffset = topOffset + oStep; - go = 1; - } - - /* cannot zoom in more, bail out */ - if(!go){ - break; - } - - DBG(15,"getEdgeIterate: zoom: %+0.4f %+0.4f %d %d\n", - minSlope,maxSlope,minOffset,maxOffset); - } - - /* topOffset is in the center of the image, - * convert to x and y intercept */ - if(topSlope != 0){ - *finYInter = topOffset - topSlope * width/2; - *finXInter = *finYInter / -topSlope; - *finSlope = topSlope; - } - else{ - *finYInter = 0; - *finXInter = 0; - *finSlope = 0; - } - - DBG(10,"getEdgeIterate: finish\n"); - - return 0; -} - -/* find the left side of paper by moving a line - * perpendicular to top slope across the image - * the 'left-most' point on the paper is the - * one with the smallest X intercept - * return x and y intercepts */ -SANE_Status -getEdgeSlope (int width, int height, int * top, int * bot, - double slope, int * finXInter, int * finYInter) -{ - - int i; - int topXInter, topYInter; - int botXInter, botYInter; - int leftCount; - - DBG(10,"getEdgeSlope: start\n"); - - topXInter = width; - topYInter = 0; - leftCount = 0; - - for(i=0;i txi){ - topXInter = txi; - topYInter = tyi; - } - - leftCount++; - if(leftCount > 5){ - break; - } - } - else{ - topXInter = width; - topYInter = 0; - leftCount = 0; - } - } - - botXInter = width; - botYInter = 0; - leftCount = 0; - - for(i=0;i -1){ - - int byi = bot[i] - (slope * i); - int bxi = byi/-slope; - - if(botXInter > bxi){ - botXInter = bxi; - botYInter = byi; - } - - leftCount++; - if(leftCount > 5){ - break; - } - } - else{ - botXInter = width; - botYInter = 0; - leftCount = 0; - } - } - - if(botXInter < topXInter){ - *finXInter = botXInter; - *finYInter = botYInter; - } - else{ - *finXInter = topXInter; - *finYInter = topYInter; - } - - DBG(10,"getEdgeSlope: finish\n"); - - return 0; -} - -/* function to do a simple rotation by a given slope, around - * a given point. The point can be outside of image to get - * proper edge alignment. Unused areas filled with bg color - * FIXME: Do in-place rotation to save memory */ -SANE_Status -rotateOnCenter (struct scanner *s, int side, - int centerX, int centerY, double slope) +/* certain scanners require the mode of the + * image to be changed in software. */ +static int +must_downsample(struct scanner *s) { - double slopeRad = -atan(slope); - double slopeSin = sin(slopeRad); - double slopeCos = cos(slopeRad); - - int bwidth = s->i.Bpl; - int pwidth = s->i.width; - int height = s->i.height; - int depth = 1; - int bg_color = s->lut[s->bg_color]; - - unsigned char * outbuf; - int i, j, k; - - DBG(10,"rotateOnCenter: start: %d %d\n",centerX,centerY); - - outbuf = malloc(s->i.bytes_tot[side]); - if(!outbuf){ - DBG(15,"rotateOnCenter: no outbuf\n"); - return SANE_STATUS_NO_MEM; - } - - switch (s->i.mode){ - - case MODE_COLOR: - depth = 3; - - case MODE_GRAYSCALE: - memset(outbuf,bg_color,s->i.bytes_tot[side]); - - for (i=0; i= pwidth) - continue; - - sourceY = centerY + (int)(-shiftY * slopeCos + shiftX * slopeSin); - if (sourceY < 0 || sourceY >= height) - continue; - - for (k=0; kbuffers[side][sourceY*bwidth+sourceX*depth+k]; - } - } - } - break; - - case MODE_LINEART: - case MODE_HALFTONE: - memset(outbuf,(bg_colorthreshold)?0xff:0x00,s->i.bytes_tot[side]); - - for (i=0; i= pwidth) - continue; - - sourceY = centerY + (int)(-shiftY * slopeCos + shiftX * slopeSin); - if (sourceY < 0 || sourceY >= height) - continue; - - /* wipe out old bit */ - outbuf[i*bwidth + j/8] &= ~(1 << (7-(j%8))); - - /* fill in new bit */ - outbuf[i*bwidth + j/8] |= - ((s->buffers[side][sourceY*bwidth + sourceX/8] - >> (7-(sourceX%8))) & 1) << (7-(j%8)); - } - } - break; + if(s->s.mode != s->i.mode + && s->compress != COMP_JPEG + ){ + return 1; } - memcpy(s->buffers[side],outbuf,s->i.bytes_tot[side]); - - free(outbuf); - - DBG(10,"rotateOnCenter: finish\n"); - return 0; } diff --git a/backend/canon_dr.conf.in b/backend/canon_dr.conf.in index 453065b..29b6db1 100644 --- a/backend/canon_dr.conf.in +++ b/backend/canon_dr.conf.in @@ -74,6 +74,7 @@ option duplex-offset 432 usb 0x04a9 0x1608 # DR-3080CII +option padded-read 1 usb 0x04a9 0x1609 # DR-2050C/SP (uses weird protocol) @@ -133,6 +134,9 @@ usb 0x1083 0x1626 # CR-190i usb 0x1083 0x162b +# P-150M +usb 0x1083 0x162c + # DR-6030C usb 0x1083 0x1638 @@ -186,6 +190,7 @@ usb 0x1083 0x1651 usb 0x1083 0x1652 # DR-F120 +option duplex-offset 1640 usb 0x1083 0x1654 # DR-M1060 diff --git a/backend/canon_dr.h b/backend/canon_dr.h index 4a19f55..d96fbba 100644 --- a/backend/canon_dr.h +++ b/backend/canon_dr.h @@ -21,12 +21,12 @@ enum scanner_Option OPT_RES, /*a range or a list*/ OPT_GEOMETRY_GROUP, + OPT_PAGE_WIDTH, + OPT_PAGE_HEIGHT, OPT_TL_X, OPT_TL_Y, OPT_BR_X, OPT_BR_Y, - OPT_PAGE_WIDTH, - OPT_PAGE_HEIGHT, OPT_ENHANCEMENT_GROUP, OPT_BRIGHTNESS, @@ -43,6 +43,7 @@ enum scanner_Option OPT_SWDESKEW, OPT_SWDESPECK, OPT_SWCROP, + OPT_SWSKIP, OPT_STAPLEDETECT, OPT_DROPOUT_COLOR_F, OPT_DROPOUT_COLOR_B, @@ -253,6 +254,7 @@ struct scanner SANE_String_Const compress_list[3]; SANE_Range compress_arg_range; SANE_Range swdespeck_range; + SANE_Range swskip_range; SANE_String_Const do_color_list[8]; /*sensor group*/ @@ -276,13 +278,13 @@ struct scanner int compress_arg; int df_length; int df_thickness; - int dropout_color_f; - int dropout_color_b; + int dropout_color[2]; int buffermode; int rollerdeskew; int swdeskew; int swdespeck; int swcrop; + int swskip; int stapledetect; /* --------------------------------------------------------------------- */ @@ -298,6 +300,24 @@ struct scanner /* the brightness/contrast LUT for dumb scanners */ unsigned char lut[256]; + /* --------------------------------------------------------------------- */ + /* values used by the software enhancment code (deskew, crop, etc) */ + SANE_Status deskew_stat; + int deskew_vals[2]; + double deskew_slope; + + int crop_vals[4]; + + /* 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 s_params; + /* --------------------------------------------------------------------- */ /* values which are set by calibration functions */ int c_res; @@ -429,9 +449,10 @@ enum { #define COLOR_INTERLACE_2510 7 #define DUPLEX_INTERLACE_NONE 0 -#define DUPLEX_INTERLACE_FFBB 1 -#define DUPLEX_INTERLACE_FBFB 2 +#define DUPLEX_INTERLACE_FfBb 1 +#define DUPLEX_INTERLACE_FBfb 2 #define DUPLEX_INTERLACE_2510 3 +#define DUPLEX_INTERLACE_fFBb 4 #define JPEG_INTERLACE_ALT 0 #define JPEG_INTERLACE_NONE 1 @@ -563,27 +584,16 @@ static SANE_Status read_from_scanner_duplex(struct scanner *s, int exact); static SANE_Status copy_simplex(struct scanner *s, unsigned char * buf, int len, int side); static SANE_Status copy_duplex(struct scanner *s, unsigned char * buf, int len); static SANE_Status copy_line(struct scanner *s, unsigned char * buf, int side); +static SANE_Status fill_image(struct scanner *s,int side); + +static int must_downsample (struct scanner *s); +static int must_fully_buffer (struct scanner *s); +static unsigned char calc_bg_color(struct scanner *s); static SANE_Status buffer_despeck(struct scanner *s, int side); static SANE_Status buffer_deskew(struct scanner *s, int side); static SANE_Status buffer_crop(struct scanner *s, int side); - -int * getTransitionsY (struct scanner *s, int side, int top); -int * getTransitionsX (struct scanner *s, int side, int top); - -SANE_Status getEdgeIterate (int width, int height, int resolution, - int * buff, double * finSlope, int * finXInter, int * finYInter); - -SANE_Status getEdgeSlope (int width, int height, int * top, int * bot, - double slope, int * finXInter, int * finYInter); - -SANE_Status rotateOnCenter (struct scanner *s, int side, - int centerX, int centerY, double slope); - -static SANE_Status getLine (int height, int width, int * buff, - int slopes, double minSlope, double maxSlope, - int offsets, int minOffset, int maxOffset, - double * finSlope, int * finOffset, int * finDensity); +static int buffer_isblank(struct scanner *s, int side); static SANE_Status load_lut (unsigned char * lut, int in_bits, int out_bits, int out_min, int out_max, int slope, int offset); @@ -606,4 +616,6 @@ static void default_globals (void); static size_t maxStringSize (const SANE_String_Const strings[]); +static void rmemcpy(void* dest, const void* src, size_t count, size_t stride); + #endif /* CANON_DR_H */ diff --git a/backend/cardscan.c b/backend/cardscan.c index 6442458..eab6500 100644 --- a/backend/cardscan.c +++ b/backend/cardscan.c @@ -3,7 +3,9 @@ This file is part of the SANE package, and implements a SANE backend for various Corex Cardscan scanners. - Copyright (C) 2007-2010 m. allan noah + Copyright (C) 2007-2015 m. allan noah + + -------------------------------------------------------------------------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -43,8 +45,6 @@ -------------------------------------------------------------------------- - This file implements a SANE backend for the Corex Cardscan 800C - The source code is divided in sections which you can easily find by searching for the tag "@@". @@ -65,6 +65,8 @@ - add has_cal_buffer config option - basic support for 600c - clean #include lines + v3, 2015-11-04, MAN + - add USB IDs for newer model 800c ################################################## DATA FROM TRACE OF WINDOWS DRIVER: @@ -224,7 +226,7 @@ four times { #include "cardscan.h" #define DEBUG 1 -#define BUILD 2 +#define BUILD 3 /* values for SANE_DEBUG_CARDSCAN env var: - errors 5 @@ -490,6 +492,16 @@ attach_one (const char *device_name) s->product_name = "Unknown"; } } + else if(vid == 0x0451){ + s->vendor_name = "Sanford"; + if(pid == 0x6250){ + s->product_name = "800c"; + } + else{ + DBG (5, "Unknown product, using default settings\n"); + s->product_name = "Unknown"; + } + } else{ DBG (5, "Unknown vendor/product, using default settings\n"); s->vendor_name = "Unknown"; @@ -862,7 +874,6 @@ sane_control_option (SANE_Handle handle, SANE_Int option, } else if (action == SANE_ACTION_SET_VALUE) { int tmp; - SANE_Word val_c; SANE_Status status; DBG (20, "sane_control_option: set value for '%s' (%d)\n", s->opt[option].name,option); @@ -883,9 +894,6 @@ sane_control_option (SANE_Handle handle, SANE_Int option, return status; } - /* may have been changed by constrain, so dont copy until now */ - val_c = *(SANE_Word *)val; - /* * Note - for those options which can assume one of a list of * valid values, we can safely assume that they will have diff --git a/backend/cardscan.conf.in b/backend/cardscan.conf.in index 3c49f26..a978e0d 100644 --- a/backend/cardscan.conf.in +++ b/backend/cardscan.conf.in @@ -11,6 +11,9 @@ # Corex Cardscan 800c usb 0x08f0 0x0005 +# Sanford Cardscan 800c +usb 0x0451 0x6250 + # Corex Cardscan 600c has_cal_buffer 0 lines_per_block 1 diff --git a/backend/coolscan.c b/backend/coolscan.c index 6828a16..239b546 100644 --- a/backend/coolscan.c +++ b/backend/coolscan.c @@ -238,7 +238,7 @@ request_sense_parse (unsigned char *sensed_data) case 0x6: if ((0x29 == asc) && (0x0 == ascq)) - DBG (1, "\t%d/%d/%d: Power On, Reset, or Bus Device Reset Occured\n", sense, asc, ascq); + DBG (1, "\t%d/%d/%d: Power On, Reset, or Bus Device Reset Occurred\n", sense, asc, ascq); else if ((0x2a == asc) && (0x1 == ascq)) DBG (1, "\t%d/%d/%d: Mode Parameters Changed\n", sense, asc, ascq); else @@ -1465,21 +1465,20 @@ static int get_inquiery_part_LS30 (Coolscan_t * s, unsigned char part) { int size; - int ret; /* Get length of reponse */ inquiry.cmd[1]=0x01; inquiry.cmd[2]=part; size=4; set_inquiry_return_size (inquiry.cmd, size); - ret = do_scsi_cmd (s->sfd, inquiry.cmd, inquiry.size, - s->buffer, size); + do_scsi_cmd (s->sfd, inquiry.cmd, inquiry.size, + s->buffer, size); size=get_inquiry_length(s->buffer); size+=4; /* then get inquiry with actual size */ set_inquiry_return_size (inquiry.cmd, size); - ret = do_scsi_cmd (s->sfd, inquiry.cmd, inquiry.size, - s->buffer, size); + do_scsi_cmd (s->sfd, inquiry.cmd, inquiry.size, + s->buffer, size); return size; } @@ -1511,18 +1510,17 @@ get_inquiery_LS30 (Coolscan_t * s) { unsigned char part; unsigned char parts[5]; - int size; int i; /* Get vector of inquiery parts */ - size=get_inquiery_part_LS30(s, (unsigned char) 0); + get_inquiery_part_LS30(s, (unsigned char) 0); /* Get the parts of inquiery */ for(i=0;i<5;i++) { parts[i]=((unsigned char *)s->buffer)[4+11+i]; } for(i=0;i<5;i++) { part=parts[i]; - size=get_inquiery_part_LS30 (s, part); + get_inquiery_part_LS30 (s, part); switch(part) { case 0x0c1:/* max size and resolution */ s->adbits = 8; @@ -2029,7 +2027,7 @@ do_cancel (Coolscan_t * scanner) do_eof (scanner); /* close pipe and reposition scanner */ - if (scanner->reader_pid != -1) + if (sanei_thread_is_valid (scanner->reader_pid)) { int exit_status; @@ -2156,7 +2154,7 @@ attach_one (const char *devName) return attach_scanner(devName, 0); } -static RETSIGTYPE +static void sigterm_handler (int signal) { signal = signal; @@ -4093,7 +4091,7 @@ sane_start (SANE_Handle handle) scanner->pipe = fds[0]; scanner->reader_fds = fds[1]; scanner->reader_pid = sanei_thread_begin( reader_process, (void*)scanner ); - if (scanner->reader_pid == -1) + if (!sanei_thread_is_valid (scanner->reader_pid)) { DBG (1, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)); @@ -4153,7 +4151,7 @@ sane_cancel (SANE_Handle handle) { Coolscan_t *s = handle; - if (s->reader_pid != -1) + if (sanei_thread_is_valid (s->reader_pid)) { sanei_thread_kill ( s->reader_pid ); sanei_thread_waitpid( s->reader_pid, NULL ); diff --git a/backend/coolscan2.c b/backend/coolscan2.c index 9f9efde..d54bf39 100644 --- a/backend/coolscan2.c +++ b/backend/coolscan2.c @@ -1755,7 +1755,8 @@ cs2_open (const char *device, cs2_interface_t interface, cs2_t ** sp) { SANE_Status status; cs2_t *s; - char *prefix = NULL, *line, *device2; + char *prefix = NULL, *line; + const char *device2; int i; int alloc_failed = 0; SANE_Device **device_list_new; diff --git a/backend/coolscan3.c b/backend/coolscan3.c index a1d6fe6..42814d1 100644 --- a/backend/coolscan3.c +++ b/backend/coolscan3.c @@ -290,7 +290,7 @@ static SANE_Status cs3_convert_options(cs3_t * s); static SANE_Status cs3_scan(cs3_t * s, cs3_scan_t type); static void *cs3_xmalloc(size_t size); static void *cs3_xrealloc(void *p, size_t size); -static void cs3_xfree(const void *p); +static void cs3_xfree(void *p); /* ========================================================================= */ @@ -332,9 +332,9 @@ sane_exit(void) DBG(10, "%s\n", __func__); for (i = 0; i < n_device_list; i++) { - cs3_xfree(device_list[i]->name); - cs3_xfree(device_list[i]->vendor); - cs3_xfree(device_list[i]->model); + cs3_xfree((void *)device_list[i]->name); + cs3_xfree((void *)device_list[i]->vendor); + cs3_xfree((void *)device_list[i]->model); cs3_xfree(device_list[i]); } cs3_xfree(device_list); @@ -1969,9 +1969,9 @@ cs3_open(const char *device, cs3_interface_t interface, cs3_t ** sp) device_list[n_device_list]->type = "film scanner"; if (alloc_failed) { - cs3_xfree(device_list[n_device_list]->name); - cs3_xfree(device_list[n_device_list]->vendor); - cs3_xfree(device_list[n_device_list]->model); + cs3_xfree((void *)device_list[n_device_list]->name); + cs3_xfree((void *)device_list[n_device_list]->vendor); + cs3_xfree((void *)device_list[n_device_list]->model); cs3_xfree(device_list[n_device_list]); } else n_device_list++; @@ -3181,8 +3181,8 @@ cs3_xrealloc(void *p, size_t size) } static void -cs3_xfree(const void *p) +cs3_xfree(void *p) { if (p) - free(p); + free(p); } diff --git a/backend/dc210.c b/backend/dc210.c index acfe99a..32da710 100644 --- a/backend/dc210.c +++ b/backend/dc210.c @@ -1232,7 +1232,6 @@ sane_start (SANE_Handle handle) my_src_ptr src; struct jpeg_error_mgr jerr; - int row_stride; pic_pck[3] = (unsigned char) Camera.current_picture_number - 1; @@ -1263,8 +1262,6 @@ sane_start (SANE_Handle handle) (void) jpeg_read_header (&cinfo, TRUE); dest_mgr = sanei_jpeg_jinit_write_ppm (&cinfo); (void) jpeg_start_decompress (&cinfo); - row_stride = cinfo.output_width * cinfo.output_components; - } Camera.scanning = SANE_TRUE; /* don't overlap scan requests */ diff --git a/backend/dc240.c b/backend/dc240.c index 001a937..74ab2e0 100644 --- a/backend/dc240.c +++ b/backend/dc240.c @@ -810,7 +810,7 @@ change_res (SANE_Int fd, SANE_Byte res) } SANE_Status -sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize) +sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { SANE_Char f[] = "sane_init"; @@ -962,7 +962,7 @@ static const SANE_Device *devlist[] = { SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool - UNUSEDARG local_only) + __sane_unused__ local_only) { DBG (127, "sane_get_devices called\n"); @@ -1290,7 +1290,7 @@ my_source_mgr; typedef my_source_mgr *my_src_ptr; METHODDEF (void) -jpeg_init_source (j_decompress_ptr UNUSEDARG cinfo) +jpeg_init_source (j_decompress_ptr __sane_unused__ cinfo) { /* nothing to do */ } @@ -1336,7 +1336,7 @@ static SANE_Int linebuffer_index = 0; METHODDEF (void) -jpeg_term_source (j_decompress_ptr UNUSEDARG cinfo) +jpeg_term_source (j_decompress_ptr __sane_unused__ cinfo) { /* no work necessary here */ } @@ -1417,7 +1417,7 @@ sane_start (SANE_Handle handle) my_src_ptr src; struct jpeg_error_mgr jerr; - SANE_Int row_stride, n; + SANE_Int n; SANE_Char f[] = "sane_start"; SANE_Char path[256]; struct cam_dirlist *e; @@ -1476,7 +1476,6 @@ sane_start (SANE_Handle handle) (void) jpeg_read_header (&cinfo, TRUE); dest_mgr = sanei_jpeg_jinit_write_ppm (&cinfo); (void) jpeg_start_decompress (&cinfo); - row_stride = cinfo.output_width * cinfo.output_components; linebuffer_size = 0; linebuffer_index = 0; @@ -1488,7 +1487,7 @@ sane_start (SANE_Handle handle) } SANE_Status -sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data, +sane_read (SANE_Handle __sane_unused__ handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { SANE_Int lines = 0; @@ -1582,7 +1581,7 @@ sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data, } void -sane_cancel (SANE_Handle UNUSEDARG handle) +sane_cancel (SANE_Handle __sane_unused__ handle) { unsigned char cancel_byte[] = { 0xe4 }; @@ -1621,8 +1620,8 @@ sane_cancel (SANE_Handle UNUSEDARG handle) } SANE_Status -sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool - UNUSEDARG non_blocking) +sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool + __sane_unused__ non_blocking) { /* sane_set_io_mode() is only valid during a scan */ if (Camera.scanning) @@ -1644,7 +1643,7 @@ sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool } SANE_Status -sane_get_select_fd (SANE_Handle UNUSEDARG handle, SANE_Int * UNUSEDARG fd) +sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { return SANE_STATUS_UNSUPPORTED; } diff --git a/backend/dc240.h b/backend/dc240.h index 3323fed..fae3628 100644 --- a/backend/dc240.h +++ b/backend/dc240.h @@ -203,12 +203,6 @@ struct cam_dirent long size; }; -#ifdef __GNUC__ -#define UNUSEDARG __attribute__ ((unused)) -#else -#define UNUSEDARG -#endif - #ifdef OLD /* This is the layout of the directory in the camera - Unfortunately, diff --git a/backend/dc25.c b/backend/dc25.c index 2c9e78c..fd7a0db 100644 --- a/backend/dc25.c +++ b/backend/dc25.c @@ -1308,7 +1308,7 @@ convert_pic (char *base_name, int format) { FILE *ifp; unsigned char pic[MAX_IMAGE_SIZE]; - int res, image_size, image_width, net_width, camera_header, components; + int res, image_width, net_width, components; struct pixmap *pp2; DBG (127, "convert_pic() called\n"); @@ -1374,10 +1374,8 @@ convert_pic (char *base_name, int format) * Setup image size with resolution */ - image_size = IMAGE_SIZE (res); image_width = WIDTH (res); net_width = image_width - LEFT_MARGIN - RIGHT_MARGIN (res); - camera_header = CAMERA_HEADER (res); components = (format & SAVE_24BITS) ? 3 : 1; /* @@ -1833,7 +1831,7 @@ change_res (int fd, unsigned char res) } SANE_Status -sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize) +sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { char dev_name[PATH_MAX], *p; size_t len; @@ -1980,7 +1978,7 @@ static const SANE_Device dev[] = { SANE_Status sane_get_devices (const SANE_Device *** device_list, - SANE_Bool UNUSEDARG local_only) + SANE_Bool __sane_unused__ local_only) { static const SANE_Device *devlist[] = { dev + 0, 0 @@ -2555,7 +2553,7 @@ sane_start (SANE_Handle handle) SANE_Status -sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data, +sane_read (SANE_Handle __sane_unused__ handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { DBG (127, "sane_read called, maxlen=%d\n", max_length); @@ -2724,15 +2722,15 @@ sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data, } void -sane_cancel (SANE_Handle UNUSEDARG handle) +sane_cancel (SANE_Handle __sane_unused__ handle) { DBG (127, "sane_cancel() called\n"); started = SANE_FALSE; } SANE_Status -sane_set_io_mode (SANE_Handle UNUSEDARG handle, - SANE_Bool UNUSEDARG non_blocking) +sane_set_io_mode (SANE_Handle __sane_unused__ handle, + SANE_Bool __sane_unused__ non_blocking) { /* sane_set_io_mode() is only valid during a scan */ if (started) @@ -2754,7 +2752,7 @@ sane_set_io_mode (SANE_Handle UNUSEDARG handle, } SANE_Status -sane_get_select_fd (SANE_Handle UNUSEDARG handle, SANE_Int UNUSEDARG * fd) +sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { return SANE_STATUS_UNSUPPORTED; } diff --git a/backend/dc25.h b/backend/dc25.h index df95271..fe12f74 100644 --- a/backend/dc25.h +++ b/backend/dc25.h @@ -211,12 +211,6 @@ struct pixmap { unsigned char *planes; }; -#ifdef __GNUC__ -#define UNUSEDARG __attribute__ ((unused)) -#else -#define UNUSEDARG -#endif - /* * Rotations */ diff --git a/backend/dell1600n_net.c b/backend/dell1600n_net.c index d19059b..3586215 100644 --- a/backend/dell1600n_net.c +++ b/backend/dell1600n_net.c @@ -929,6 +929,7 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize) { unsigned int i, j; + size_t lineBufFree; char itemBuf[16] = { 0 }, lineBuf[256] = { 0 }; @@ -943,7 +944,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize) sprintf (itemBuf, "%02x ", (const unsigned int) buf[i]); - strncat (lineBuf, itemBuf, sizeof (lineBuf)); + lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1; + strncat (lineBuf, itemBuf, lineBufFree); if ((i + 1) % 16) continue; @@ -960,7 +962,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize) { sprintf (itemBuf, "."); } - strncat (lineBuf, itemBuf, sizeof (lineBuf)); + lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1; + strncat (lineBuf, itemBuf, lineBufFree); } /* for j */ @@ -974,7 +977,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize) for (j = (i % 16); j < 16; ++j) { - strncat (lineBuf, " ", sizeof (lineBuf)); + lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1; + strncat (lineBuf, " ", lineBufFree); } for (j = 1 + i - ((i + 1) % 16); j < i; ++j) { @@ -986,7 +990,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize) { strcpy (itemBuf, "."); } - strncat (lineBuf, itemBuf, sizeof (lineBuf)); + lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1; + strncat (lineBuf, itemBuf, lineBufFree); } DBG (debugLevel, "%s\n", lineBuf); } @@ -1335,7 +1340,7 @@ ProcessUdpResponse (unsigned char *pData, size_t size, { unsigned short messageSize, nameSize, valueSize; - unsigned char *pItem, *pEnd, *pValue; + unsigned char *pItem, *pEnd; char sockBuf[SOCK_BUF_SIZE], *pName; struct ComBuf tcpBuf; int nread; @@ -1376,8 +1381,6 @@ ProcessUdpResponse (unsigned char *pData, size_t size, valueSize = (((unsigned short) pItem[0]) << 8) | pItem[1]; pItem += 2; - pValue = pItem; - pItem += valueSize; /* process the item */ diff --git a/backend/dll.c b/backend/dll.c index 5264f11..5eaa046 100644 --- a/backend/dll.c +++ b/backend/dll.c @@ -69,6 +69,26 @@ #if defined(HAVE_DLOPEN) && defined(HAVE_DLFCN_H) # include + /* This works around a pedantic GCC compiler warning. The ISO C + standard says that the behaviour of converting an object pointer + like the void * returned by dlsym() to a function pointer like + void *(*)() is implementation defined. POSIX though guarantees + that this works fine. + + Workaround based on http://stackoverflow.com/a/36385690. Turns + off pedantic warnings for the duration of the definition only. + */ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpedantic" +typedef void *(*func_ptr)(void); + +func_ptr +posix_dlsym (void *handle, const char *func) +{ + return dlsym (handle, func); +} +# pragma GCC diagnostic pop + /* Older versions of dlopen() don't define RTLD_NOW and RTLD_LAZY. They all seem to use a mode of 1 to indicate RTLD_NOW and some do not support RTLD_LAZY at all. Hence, unless defined, we define @@ -430,15 +450,17 @@ load (struct backend *be) if (path) { - src_len = strlen (path) + strlen (LIBDIR) + 1 + 1; + src_len = strlen (path) + strlen (DIR_SEP) + strlen(LIBDIR) + 1; src = malloc (src_len); if (!src) { DBG (1, "load: malloc failed: %s\n", strerror (errno)); return SANE_STATUS_NO_MEM; } + if (orig_src) + free (orig_src); orig_src = src; - snprintf (src, src_len, "%s:%s", path, LIBDIR); + snprintf (src, src_len, "%s%s%s", path, DIR_SEP, LIBDIR); } else { @@ -534,7 +556,7 @@ load (struct backend *be) /* First try looking up the symbol without a leading underscore. */ #ifdef HAVE_DLOPEN - op = (void *(*)(void)) dlsym (be->handle, funcname + 1); + op = posix_dlsym (be->handle, funcname + 1); #elif defined(HAVE_SHL_LOAD) shl_findsym ((shl_t *) & (be->handle), funcname + 1, TYPE_UNDEFINED, &op); @@ -559,7 +581,7 @@ load (struct backend *be) { /* Try again, with an underscore prepended. */ #ifdef HAVE_DLOPEN - op = (void *(*)(void)) dlsym (be->handle, funcname); + op = posix_dlsym (be->handle, funcname); #elif defined(HAVE_SHL_LOAD) shl_findsym (be->handle, funcname, TYPE_UNDEFINED, &op); #elif defined(HAVE_NSLINKMODULE) diff --git a/backend/dll.conf.in b/backend/dll.conf.in index ee6f2f1..3ee5428 100644 --- a/backend/dll.conf.in +++ b/backend/dll.conf.in @@ -1,4 +1,12 @@ -# enable the next line if you want to allow access through the network: +# dll.conf - Configuration file for the SANE dynamic backend loader +# +# Backends can also be enabled by configuration snippets under the dll.d/ +# directory -- third party backends can drop their configuration file in +# this in this directory, named after the backend. +# +# The next line enables the network backend; comment it out if you don't +# need to use a remote SANE scanner over the network -- see sane-net(5) +# and saned(8) for details. net abaton agfafocus diff --git a/backend/dmc.c b/backend/dmc.c index 7fc2ae9..c5c57c4 100644 --- a/backend/dmc.c +++ b/backend/dmc.c @@ -1030,7 +1030,6 @@ sane_control_option(SANE_Handle handle, SANE_Int option, { DMC_Camera *c; SANE_Word cap; - SANE_Status status; int i; if (info) *info = 0; @@ -1069,7 +1068,7 @@ sane_control_option(SANE_Handle handle, SANE_Int option, case OPT_IMAGE_MODE: for (i=0; ival[OPT_IMAGE_MODE].s = (SANE_String) ValidModes[i]; if (info) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; diff --git a/backend/epjitsu-cmd.h b/backend/epjitsu-cmd.h index 77793df..40a5c1a 100644 --- a/backend/epjitsu-cmd.h +++ b/backend/epjitsu-cmd.h @@ -47,40 +47,36 @@ static unsigned char coarseCalData_S1100[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -/*************** fi-60F 150dpi *************/ -/* 1b d1 (set window) before coarse cal (read 1 line of 0x1c20 bytes) */ -static unsigned char setWindowCoarseCal_FI60F_150[] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x2c, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, -0x00, 0x05, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/*************** fi-60F 300dpi gray *************/ +#if 0 +static unsigned char setWindowScan_FI60F_300_g[] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x2c, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x06, 0xd5, 0x00, 0x00, +0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x80, 0x80, 0x01, 0x6c, 0x01, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -/* 1b d1 (set window) before fine cal (read 16 lines of 0x1c20 bytes) */ -static unsigned char setWindowFineCal_FI60F_150[] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x03, 0x20, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x60, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, -0x00, 0x05, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x80, 0x80, 0x00, 0x10, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + +/*************** fi-60F 400dpi gray *************/ +static unsigned char setWindowScan_FI60F_400_g[] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x58, 0x01, 0x90, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x09, 0x1c, 0x00, 0x00, +0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x80, 0x80, 0x01, 0xca, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -/* 1b d1 (set window) before gain/offset tables (write 1 line of 0x3840 bytes) */ -static unsigned char setWindowSendCal_FI60F_150[] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x03, 0x20, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x60, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, -0x00, 0x05, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + +/*************** fi-60F 600dpi gray *************/ +static unsigned char setWindowScan_FI60F_600_g[] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x58, 0x02, 0x58, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x0d, 0xaa, 0x00, 0x00, +0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x80, 0x80, 0x01, 0xca, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -/* 1b c3 (gain?) command header */ -static unsigned char sendCal1Header_FI60F_150[] = { /* plus 0x3840 data bytes */ -0x8c, 0x0f, 0x8c, 0x0f, 0x8c, 0x0f, 0x8c, 0x0f, 0x8c, 0x0f, 0x8c, 0x0f, 0x00, 0x04 -}; -/* 1b c4 (offset?) command header */ -static unsigned char sendCal2Header_FI60F_150[] = { -0x39, 0x3f, 0x39, 0x3f, 0x39, 0x3f, 0x07 -}; -/* 1b d1 (set window) before scan */ +#endif + +/*************** fi-60F 150dpi *************/ static unsigned char setWindowScan_FI60F_150[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x60, 0x00, 0x00, 0x03, 0x6b, 0x00, 0x00, @@ -89,6 +85,15 @@ static unsigned char setWindowScan_FI60F_150[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +/*************** fi-60F 200dpi *************/ +static unsigned char setWindowScan_FI60F_200[] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x00, 0xc8, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x60, 0x00, 0x00, 0x04, 0x8e, 0x00, 0x00, +0x00, 0x05, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x80, 0x80, 0x01, 0x48, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + /*************** fi-60F 300dpi *************/ /* 1b d1 (set window) before coarse cal (read 1 line of 0x1c20 bytes) */ static unsigned char setWindowCoarseCal_FI60F_300[] = { @@ -131,6 +136,15 @@ static unsigned char setWindowScan_FI60F_300[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +/*************** fi-60F 400dpi *************/ +static unsigned char setWindowScan_FI60F_400[] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x58, 0x01, 0x90, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x20, 0x00, 0x00, 0x09, 0x1c, 0x00, 0x00, +0x00, 0x05, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x80, 0x80, 0x01, 0x3d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + /*************** fi-60F 600dpi *************/ /* 1b d1 (set window) before coarse cal (read 1 line of 0x2160 bytes) */ static unsigned char setWindowCoarseCal_FI60F_600[] = { diff --git a/backend/epjitsu.c b/backend/epjitsu.c index 7d987dc..ce79a20 100644 --- a/backend/epjitsu.c +++ b/backend/epjitsu.c @@ -1,6 +1,14 @@ /* sane - Scanner Access Now Easy. - This file is part of the SANE package. + This file implements a SANE backend for the Fujitsu fi-60F, the + ScanSnap S300/S1300, and (hopefully) other Epson-based scanners. + + Copyright 2007-2015 by m. allan noah + Copyright 2009 by Richard Goedeken + + Development funded by Microdea, Inc., TrueCheck, Inc. and Archivista, GmbH + + -------------------------------------------------------------------------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -40,16 +48,6 @@ -------------------------------------------------------------------------- - This file implements a SANE backend for the Fujitsu fi-60F, the - ScanSnap S300/S1300, and (hopefully) other Epson-based scanners. - - Copyright 2007-2010 by m. allan noah - Copyright 2009 by Richard Goedeken - - Development funded by Microdea, Inc., TrueCheck, Inc. and Archivista, GmbH - - -------------------------------------------------------------------------- - The source code is divided in sections which you can easily find by searching for the tag "@@". @@ -151,6 +149,14 @@ - call change_params after changing page_width v28 2015-03-23, MAN - call get_hardware_status before starting scan + v29 2017-03-18, MAN + - fix infinite loop when scaling in Y direction + v30 2017-03-21, MAN + - fix image truncation when using 150 DPI in Y direction + - add 200 and 400 DPI Y direction support for fi-60F/65F + v31 2017-04-09, MAN + - hardware gray support for fi-60F/65F (disabled pending calibration) + - merge fi-60F/65F settings SANE FLOW DIAGRAM @@ -199,7 +205,7 @@ #include "epjitsu-cmd.h" #define DEBUG 1 -#define BUILD 28 +#define BUILD 31 #ifndef MAX3 #define MAX3(a,b,c) ((a) > (b) ? ((a) > (c) ? a : c) : ((b) > (c) ? b : c)) @@ -1770,6 +1776,7 @@ update_transfer_totals(struct transfer * t) /* we hard-code the list (determined from usb snoops) here */ struct model_res { int model; + int mode; int x_res; int y_res; int usb_power; @@ -1802,141 +1809,153 @@ struct model_res { static struct model_res settings[] = { /*S300 AC*/ -/* model xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ - { MODEL_S300, 150, 150, 0, 1296, 32, 2662, 32, 4256*3, 1480*3, 1296, 41, 8512*3, 2960*3, 2592, +/* model mode xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ + { MODEL_S300, MODE_COLOR, 150, 150, 0, 1296, 32, 2662, 32, 4256*3, 1480*3, 1296, 41, 8512*3, 2960*3, 2592, setWindowCoarseCal_S300_150, setWindowFineCal_S300_150, setWindowSendCal_S300_150, sendCal1Header_S300_150, sendCal2Header_S300_150, setWindowScan_S300_150 }, - { MODEL_S300, 225, 200, 0, 1944, 32, 3993, 32, 6144*3, 2100*3, 1944, 28, 8192*3, 2800*3, 2592, + { MODEL_S300, MODE_COLOR, 225, 200, 0, 1944, 32, 3993, 32, 6144*3, 2100*3, 1944, 28, 8192*3, 2800*3, 2592, setWindowCoarseCal_S300_225, setWindowFineCal_S300_225, setWindowSendCal_S300_225, sendCal1Header_S300_225, sendCal2Header_S300_225, setWindowScan_S300_225 }, - { MODEL_S300, 300, 300, 0, 2592, 32, 5324, 32, 8192*3, 2800*3, 2592, 21, 8192*3, 2800*3, 2592, + { MODEL_S300, MODE_COLOR, 300, 300, 0, 2592, 32, 5324, 32, 8192*3, 2800*3, 2592, 21, 8192*3, 2800*3, 2592, setWindowCoarseCal_S300_300, setWindowFineCal_S300_300, setWindowSendCal_S300_300, sendCal1Header_S300_300, sendCal2Header_S300_300, setWindowScan_S300_300 }, - { MODEL_S300, 600, 600, 0, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, + { MODEL_S300, MODE_COLOR, 600, 600, 0, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, setWindowCoarseCal_S300_600, setWindowFineCal_S300_600, setWindowSendCal_S300_600, sendCal1Header_S300_600, sendCal2Header_S300_600, setWindowScan_S300_600 }, /*S300 USB*/ -/* model xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ - { MODEL_S300, 150, 150, 1, 1296, 32, 2662, 32, 7216*3, 2960*3, 1296, 24, 14432*3, 5920*3, 2592, +/* model mode xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ + { MODEL_S300, MODE_COLOR, 150, 150, 1, 1296, 32, 2662, 32, 7216*3, 2960*3, 1296, 24, 14432*3, 5920*3, 2592, setWindowCoarseCal_S300_150_U, setWindowFineCal_S300_150_U, setWindowSendCal_S300_150_U, sendCal1Header_S300_150_U, sendCal2Header_S300_150_U, setWindowScan_S300_150_U }, - { MODEL_S300, 225, 200, 1, 1944, 32, 3993, 32, 10584*3, 4320*3, 1944, 16, 14112*3, 5760*3, 2592, + { MODEL_S300, MODE_COLOR, 225, 200, 1, 1944, 32, 3993, 32, 10584*3, 4320*3, 1944, 16, 14112*3, 5760*3, 2592, setWindowCoarseCal_S300_225_U, setWindowFineCal_S300_225_U, setWindowSendCal_S300_225_U, sendCal1Header_S300_225_U, sendCal2Header_S300_225_U, setWindowScan_S300_225_U }, - { MODEL_S300, 300, 300, 1, 2592, 32, 5324, 32, 15872*3, 6640*3, 2592, 11, 15872*3, 6640*3, 2592, + { MODEL_S300, MODE_COLOR, 300, 300, 1, 2592, 32, 5324, 32, 15872*3, 6640*3, 2592, 11, 15872*3, 6640*3, 2592, setWindowCoarseCal_S300_300_U, setWindowFineCal_S300_300_U, setWindowSendCal_S300_300_U, sendCal1Header_S300_300_U, sendCal2Header_S300_300_U, setWindowScan_S300_300_U }, - { MODEL_S300, 600, 600, 1, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, + { MODEL_S300, MODE_COLOR, 600, 600, 1, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, setWindowCoarseCal_S300_600, setWindowFineCal_S300_600, setWindowSendCal_S300_600, sendCal1Header_S300_600, sendCal2Header_S300_600, setWindowScan_S300_600 }, /*S1300i AC*/ -/* model xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ - { MODEL_S1300i, 150, 150, 0, 1296, 32, 2662, 32, 4016*3, 1360*3, 1296, 43, 8032*3, 2720*3, 2592, +/* model mode xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ + { MODEL_S1300i, MODE_COLOR, 150, 150, 0, 1296, 32, 2662, 32, 4016*3, 1360*3, 1296, 43, 8032*3, 2720*3, 2592, setWindowCoarseCal_S1300i_150, setWindowFineCal_S1300i_150, setWindowSendCal_S1300i_150, sendCal1Header_S1300i_150, sendCal2Header_S1300i_150, setWindowScan_S1300i_150 }, - { MODEL_S1300i, 225, 200, 0, 1944, 32, 3993, 32, 6072*3, 2063*3, 1944, 28, 8096*3, 2752*3, 2592, + { MODEL_S1300i, MODE_COLOR, 225, 200, 0, 1944, 32, 3993, 32, 6072*3, 2063*3, 1944, 28, 8096*3, 2752*3, 2592, setWindowCoarseCal_S1300i_225, setWindowFineCal_S1300i_225, setWindowSendCal_S1300i_225, sendCal1Header_S1300i_225, sendCal2Header_S1300i_225, setWindowScan_S1300i_225 }, - { MODEL_S1300i, 300, 300, 0, 2592, 32, 5324, 32, 8096*3, 2751*3, 2592, 21, 8096*3, 2752*3, 2592, + { MODEL_S1300i, MODE_COLOR, 300, 300, 0, 2592, 32, 5324, 32, 8096*3, 2751*3, 2592, 21, 8096*3, 2752*3, 2592, setWindowCoarseCal_S1300i_300, setWindowFineCal_S1300i_300, setWindowSendCal_S1300i_300, sendCal1Header_S1300i_300, sendCal2Header_S1300i_300, setWindowScan_S1300i_300 }, /*NOTE: S1300i uses S300 data blocks for remainder*/ - { MODEL_S1300i, 600, 600, 0, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, + { MODEL_S1300i, MODE_COLOR, 600, 600, 0, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, setWindowCoarseCal_S300_600, setWindowFineCal_S300_600, setWindowSendCal_S300_600, sendCal1Header_S300_600, sendCal2Header_S300_600, setWindowScan_S300_600 }, /*S1300i USB*/ -/* model xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ - { MODEL_S1300i, 150, 150, 1, 1296, 32, 2662, 32, 7216*3, 2960*3, 1296, 24, 14432*3, 5920*3, 2592, +/* model mode xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ + { MODEL_S1300i, MODE_COLOR, 150, 150, 1, 1296, 32, 2662, 32, 7216*3, 2960*3, 1296, 24, 14432*3, 5920*3, 2592, setWindowCoarseCal_S300_150_U, setWindowFineCal_S300_150_U, setWindowSendCal_S300_150_U, sendCal1Header_S1300i_USB, sendCal2Header_S1300i_USB, setWindowScan_S300_150_U }, - { MODEL_S1300i, 225, 200, 1, 1944, 32, 3993, 32, 10584*3, 4320*3, 1944, 16, 14112*3, 5760*3, 2592, + { MODEL_S1300i, MODE_COLOR, 225, 200, 1, 1944, 32, 3993, 32, 10584*3, 4320*3, 1944, 16, 14112*3, 5760*3, 2592, setWindowCoarseCal_S300_225_U, setWindowFineCal_S300_225_U, setWindowSendCal_S300_225_U, sendCal1Header_S1300i_USB, sendCal2Header_S1300i_USB, setWindowScan_S300_225_U }, - { MODEL_S1300i, 300, 300, 1, 2592, 32, 5324, 32, 15872*3, 6640*3, 2592, 11, 15872*3, 6640*3, 2592, + { MODEL_S1300i, MODE_COLOR, 300, 300, 1, 2592, 32, 5324, 32, 15872*3, 6640*3, 2592, 11, 15872*3, 6640*3, 2592, setWindowCoarseCal_S300_300_U, setWindowFineCal_S300_300_U, setWindowSendCal_S300_300_U, sendCal1Header_S1300i_USB, sendCal2Header_S1300i_USB, setWindowScan_S300_300_U }, - { MODEL_S1300i, 600, 600, 1, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, + { MODEL_S1300i, MODE_COLOR, 600, 600, 1, 5184, 32, 10648, 32, 16064*3, 5440*3, 5184, 10, 16064*3, 5440*3, 5184, setWindowCoarseCal_S300_600, setWindowFineCal_S300_600, setWindowSendCal_S300_600, sendCal1Header_S1300i_USB, sendCal2Header_S1300i_USB, setWindowScan_S300_600 }, - /*fi-60F*/ -/* model xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ - { MODEL_FI60F, 300, 150, 0, 1296, 32, 875, 32, 2400*3, 958*3, 432, 72, 2400*3, 958*3, 432, - setWindowCoarseCal_FI60F_150, setWindowFineCal_FI60F_150, - setWindowSendCal_FI60F_150, sendCal1Header_FI60F_150, - sendCal2Header_FI60F_150, setWindowScan_FI60F_150 }, - - { MODEL_FI60F, 300, 300, 0, 1296, 32, 1749, 32, 2400*3, 958*3, 432, 72, 2400*3, 958*3, 432, + /*fi-60F/65F GRAY */ +/* model mode xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ +/* disabled until calibration code supports grayscale + { MODEL_FI60F | MODEL_FI65F, MODE_GRAYSCALE, 300, 300, 0, 1296, 32, 1749, 32, 1440, 480, 432, 364, 2400*3, 958*3, 432, setWindowCoarseCal_FI60F_300, setWindowFineCal_FI60F_300, setWindowSendCal_FI60F_300, sendCal1Header_FI60F_300, - sendCal2Header_FI60F_300, setWindowScan_FI60F_300 }, + sendCal2Header_FI60F_300, setWindowScan_FI60F_300_g }, - { MODEL_FI60F, 600, 600, 0, 2592, 32, 3498, 32, 2848*3, 978*3, 864, 61, 2848*3, 978*3, 864, + { MODEL_FI60F | MODEL_FI65F, MODE_GRAYSCALE, 600, 400, 0, 2592, 32, 2332, 32, 2592, 864, 864, 202, 2848*3, 978*3, 864, setWindowCoarseCal_FI60F_600, setWindowFineCal_FI60F_600, setWindowSendCal_FI60F_600, sendCal1Header_FI60F_600, - sendCal2Header_FI60F_600, setWindowScan_FI60F_600 }, + sendCal2Header_FI60F_600, setWindowScan_FI60F_400_g }, - /*fi-65F*/ -/* model xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ - { MODEL_FI65F, 300, 150, 0, 1296, 32, 875, 32, 2400*3, 958*3, 432, 72, 2400*3, 958*3, 432, - setWindowCoarseCal_FI60F_150, setWindowFineCal_FI60F_150, - setWindowSendCal_FI60F_150, sendCal1Header_FI60F_150, - sendCal2Header_FI60F_150, setWindowScan_FI60F_150 }, + { MODEL_FI60F | MODEL_FI65F, MODE_GRAYSCALE, 600, 600, 0, 2592, 32, 3498, 32, 2592, 864, 864, 202, 2848*3, 978*3, 864, + setWindowCoarseCal_FI60F_600, setWindowFineCal_FI60F_600, + setWindowSendCal_FI60F_600, sendCal1Header_FI60F_600, + sendCal2Header_FI60F_600, setWindowScan_FI60F_600_g }, +*/ + + /*fi-60F/65F*/ +/* model mode xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ + { MODEL_FI60F | MODEL_FI65F, MODE_COLOR, 300, 150, 0, 1296, 32, 875, 32, 2400*3, 958*3, 432, 72, 2400*3, 958*3, 432, + setWindowCoarseCal_FI60F_300, setWindowFineCal_FI60F_300, + setWindowSendCal_FI60F_300, sendCal1Header_FI60F_300, + sendCal2Header_FI60F_300, setWindowScan_FI60F_150 }, - { MODEL_FI65F, 300, 300, 0, 1296, 32, 1749, 32, 2400*3, 958*3, 432, 72, 2400*3, 958*3, 432, + { MODEL_FI60F | MODEL_FI65F, MODE_COLOR, 300, 200, 0, 1296, 32, 1166, 32, 2400*3, 958*3, 432, 72, 2400*3, 958*3, 432, + setWindowCoarseCal_FI60F_300, setWindowFineCal_FI60F_300, + setWindowSendCal_FI60F_300, sendCal1Header_FI60F_300, + sendCal2Header_FI60F_300, setWindowScan_FI60F_200 }, + + { MODEL_FI60F | MODEL_FI65F, MODE_COLOR, 300, 300, 0, 1296, 32, 1749, 32, 2400*3, 958*3, 432, 72, 2400*3, 958*3, 432, setWindowCoarseCal_FI60F_300, setWindowFineCal_FI60F_300, setWindowSendCal_FI60F_300, sendCal1Header_FI60F_300, sendCal2Header_FI60F_300, setWindowScan_FI60F_300 }, - { MODEL_FI65F, 600, 600, 0, 2592, 32, 3498, 32, 2848*3, 978*3, 864, 61, 2848*3, 978*3, 864, + { MODEL_FI60F | MODEL_FI65F, MODE_COLOR, 600, 400, 0, 2592, 32, 2332, 32, 2848*3, 978*3, 864, 61, 2848*3, 978*3, 864, + setWindowCoarseCal_FI60F_600, setWindowFineCal_FI60F_600, + setWindowSendCal_FI60F_600, sendCal1Header_FI60F_600, + sendCal2Header_FI60F_600, setWindowScan_FI60F_400 }, + + { MODEL_FI60F | MODEL_FI65F, MODE_COLOR, 600, 600, 0, 2592, 32, 3498, 32, 2848*3, 978*3, 864, 61, 2848*3, 978*3, 864, setWindowCoarseCal_FI60F_600, setWindowFineCal_FI60F_600, setWindowSendCal_FI60F_600, sendCal1Header_FI60F_600, sendCal2Header_FI60F_600, setWindowScan_FI60F_600 }, /*S1100 USB*/ -/* model xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ - { MODEL_S1100, 300, 300, 1, 2592, 32, 5324, 32, 8912, 3160, 2592, 58, 8912, 3160, 2592, +/* model mode xres yres u mxx mnx mxy mny lin_s pln_s pln_w bh cls cps cpw */ + { MODEL_S1100, MODE_COLOR, 300, 300, 1, 2592, 32, 5324, 32, 8912, 3160, 2592, 58, 8912, 3160, 2592, setWindowCoarseCal_S1100_300_U, setWindowFineCal_S1100_300_U, setWindowSendCal_S1100_300_U, sendCal1Header_S1100_300_U, sendCal2Header_S1100_300_U, setWindowScan_S1100_300_U }, - { MODEL_S1100, 600, 600, 1, 5184, 32, 10648, 32, 15904, 5360, 5184, 32, 15904, 5360, 5184, + { MODEL_S1100, MODE_COLOR, 600, 600, 1, 5184, 32, 10648, 32, 15904, 5360, 5184, 32, 15904, 5360, 5184, setWindowCoarseCal_S1100_600_U, setWindowFineCal_S1100_600_U, setWindowSendCal_S1100_600_U, sendCal1Header_S1100_600_U, sendCal2Header_S1100_600_U, setWindowScan_S1100_600_U }, - { MODEL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + { MODEL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL }, }; @@ -1955,7 +1974,8 @@ change_params(struct scanner *s) DBG (10, "change_params: start\n"); do { - if(settings[i].model == s->model + if(settings[i].model & s->model + && settings[i].mode <= s->mode && settings[i].x_res >= s->resolution && settings[i].y_res >= s->resolution && settings[i].usb_power == s->usb_power @@ -2038,11 +2058,12 @@ change_params(struct scanner *s) s->br_x = (s->max_x + s->page_width)/2; /*=============================================================*/ - /* set up the calibration structs */ + /* set up the calibration scan structs */ /* generally full width, short height, full resolution */ s->cal_image.line_stride = settings[i].cal_line_stride; s->cal_image.plane_stride = settings[i].cal_plane_stride; s->cal_image.plane_width = settings[i].cal_plane_width; + s->cal_image.mode = MODE_COLOR; s->cal_image.x_res = settings[i].x_res; s->cal_image.y_res = settings[i].y_res; s->cal_image.raw_data = NULL; @@ -2052,38 +2073,19 @@ change_params(struct scanner *s) s->cal_data.line_stride = settings[i].cal_line_stride * 2; s->cal_data.plane_stride = settings[i].cal_plane_stride * 2; s->cal_data.plane_width = settings[i].cal_plane_width; + s->cal_data.mode = MODE_COLOR; s->cal_data.x_res = settings[i].x_res; s->cal_data.y_res = settings[i].y_res; s->cal_data.raw_data = NULL; s->cal_data.image = &s->sendcal; /*=============================================================*/ - /* set up the input scan structs */ - s->block_xfr.line_stride = settings[i].line_stride; - s->block_xfr.plane_stride = settings[i].plane_stride; - s->block_xfr.plane_width = settings[i].plane_width; - s->block_xfr.x_res = settings[i].x_res; - s->block_xfr.y_res = settings[i].y_res; - s->block_xfr.raw_data = NULL; - s->block_xfr.image = &s->block_img; - - /* set up the block image used during scanning operation */ - /* note that this is the same width/x_res as the final output image */ - /* but the height/y_res are the same as block_xfr */ - width = (s->block_xfr.plane_width*s->resolution/settings[i].x_res) * img_heads; - s->block_img.width_pix = width; - s->block_img.width_bytes = width * 3; - s->block_img.height = settings[i].block_height; - s->block_img.x_res = s->resolution; - s->block_img.y_res = settings[i].y_res; - s->block_img.pages = img_pages; - s->block_img.buffer = NULL; - /* set up the calibration image blocks */ width = s->cal_image.plane_width * img_heads; s->coarsecal.width_pix = s->darkcal.width_pix = s->lightcal.width_pix = width; s->coarsecal.width_bytes = s->darkcal.width_bytes = s->lightcal.width_bytes = width * 3; s->coarsecal.height = 1; + s->coarsecal.mode = MODE_COLOR; s->coarsecal.x_res = s->darkcal.x_res = s->lightcal.x_res = settings[i].x_res; s->coarsecal.y_res = s->darkcal.y_res = s->lightcal.y_res = settings[i].y_res; s->darkcal.height = s->lightcal.height = 16; @@ -2095,13 +2097,18 @@ change_params(struct scanner *s) s->sendcal.width_pix = width; s->sendcal.width_bytes = width * 6; /* 2 bytes of cal data per pixel component */ s->sendcal.height = 1; + s->sendcal.mode = MODE_COLOR; s->sendcal.x_res = settings[i].x_res; s->sendcal.y_res = settings[i].y_res; s->sendcal.pages = img_pages; s->sendcal.buffer = NULL; + /*=============================================================*/ /* set up the fullscan parameters */ - s->fullscan.width_bytes = s->block_xfr.line_stride; + /* this is bookkeeping for what we actually pull from the scanner */ + /* note that this has no image, just dimensions and counters */ + s->fullscan.width_bytes = settings[i].line_stride; + s->fullscan.mode = settings[i].mode; s->fullscan.x_res = settings[i].x_res; s->fullscan.y_res = settings[i].y_res; if(s->source == SOURCE_FLATBED || !s->page_height) @@ -2115,9 +2122,35 @@ change_params(struct scanner *s) s->fullscan.height = SCANNER_UNIT_TO_PIX((s->page_height + s->tl_y + s->adf_height_padding), s->fullscan.y_res); } + /*=============================================================*/ + /* set up the input block raw struct */ + /* this holds up to 512k of raw scan data */ + s->block_xfr.line_stride = settings[i].line_stride; + s->block_xfr.plane_stride = settings[i].plane_stride; + s->block_xfr.plane_width = settings[i].plane_width; + s->block_xfr.mode = settings[i].mode; + s->block_xfr.x_res = settings[i].x_res; + s->block_xfr.y_res = settings[i].y_res; + s->block_xfr.raw_data = NULL; + s->block_xfr.image = &s->block_img; + + /* set up the input block image struct */ + /* note that this is the same width/x_res as the final output image */ + /* but the mode, height and y_res are the same as block_xfr */ + width = (settings[i].max_x * s->resolution / settings[i].x_res); + s->block_img.width_pix = width; + s->block_img.width_bytes = width * (settings[i].mode == MODE_COLOR ? 3 : 1); + s->block_img.height = settings[i].block_height; + s->block_img.mode = settings[i].mode; + s->block_img.x_res = s->resolution; + s->block_img.y_res = settings[i].y_res; + s->block_img.pages = img_pages; + s->block_img.buffer = NULL; + /*=============================================================*/ /* set up the output image structs */ /* output image might be different from scan due to interpolation */ + s->front.mode = s->mode; s->front.x_res = s->resolution; s->front.y_res = s->resolution; if(s->source == SOURCE_FLATBED) @@ -2170,6 +2203,7 @@ change_params(struct scanner *s) /* back settings always same as front settings */ s->back.width_pix = s->front.width_pix; s->back.width_bytes = s->front.width_bytes; + s->back.mode = s->front.mode; s->back.x_res = s->front.x_res; s->back.y_res = s->front.y_res; s->back.height = s->front.height; @@ -2182,6 +2216,7 @@ change_params(struct scanner *s) /* dynamic threshold temp buffer, in gray */ s->dt.width_pix = s->front.width_pix; s->dt.width_bytes = s->front.width_pix; + s->dt.mode = MODE_GRAYSCALE; s->dt.x_res = s->front.x_res; s->dt.y_res = s->front.y_res; s->dt.height = 1; @@ -3955,7 +3990,7 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len { DBG (15, "sane_read: block buffer full\n"); - /* convert the raw data into normal packed pixel data */ + /* convert the raw color data into normal packed pixel data */ descramble_raw(s, &s->block_xfr); s->block_xfr.done = 0; @@ -4095,6 +4130,8 @@ six5 (struct scanner *s) /* de-scrambles the raw data from the scanner into the image buffer */ /* the output image might be lower dpi than input image, so we scale horizontally */ +/* if the input image is mirrored left to right, we do not correct it here */ +/* if the input image has padding (at the end or between heads), it is removed here */ static SANE_Status descramble_raw(struct scanner *s, struct transfer * tp) { @@ -4103,6 +4140,13 @@ descramble_raw(struct scanner *s, struct transfer * tp) int height = tp->total_bytes / tp->line_stride; int i, j, k; + /* raw gray data handled in another function */ + if(tp->mode == MODE_GRAYSCALE){ + return descramble_raw_gray(s, tp); + } + + DBG(15, "descramble_raw: start\n"); + if (s->model == MODEL_S300 || s->model == MODEL_S1300i) { for (i = 0; i < 2; i++){ /* page, front/back */ for (j = 0; j < height; j++){ /* row (y)*/ @@ -4233,6 +4277,47 @@ descramble_raw(struct scanner *s, struct transfer * tp) } } + DBG(15, "descramble_raw: finish %d\n", ret); + + return ret; +} + +/* de-scrambles the raw gray data from the scanner into the image buffer */ +/* the output image might be lower dpi than input image, so we scale horizontally */ +/* if the input image is mirrored left to right, we do not correct it here */ +/* if the input image has padding (at the end or between heads), it is removed here */ +static SANE_Status +descramble_raw_gray(struct scanner *s, struct transfer * tp) +{ + SANE_Status ret = SANE_STATUS_GOOD; + int height = tp->total_bytes / tp->line_stride; + int row, col_out; + + DBG(15, "descramble_raw_gray: start\n"); + + if (s->model == MODEL_FI60F || s->model == MODEL_FI65F) { + for (row = 0; row < height; row++){ + + unsigned char *p_in = tp->raw_data + row * tp->line_stride; + unsigned char *p_out = tp->image->buffer + row * tp->image->width_pix; + + for (col_out = 0; col_out < tp->image->width_pix; col_out++){ + int col_in = col_out * tp->x_res/tp->image->x_res; + int offset = col_in%tp->plane_width; + int step = col_in/tp->plane_width; + + *p_out = *(p_in + offset*3 + step); + p_out++; + } + } + } + + else{ + DBG(5, "internal error: descramble_raw_gray not supported\n"); + ret = SANE_STATUS_INVAL; + } + + DBG(15, "descramble_raw_gray: finish %d\n", ret); return ret; } @@ -4313,8 +4398,10 @@ read_from_scanner(struct scanner *s, struct transfer * tp) } /* copies block buffer into front or back image buffer */ -/* converts pixel data from RGB Color to the output format */ +/* converts pixel data from input mode (color/gray) to output mode (color/gray/binary) */ /* the output image might be lower dpi than input image, so we scale vertically */ +/* the input is already scaled horizontally and padding skipped if required */ +/* if the input is mirrored left to right, we fix it here */ static SANE_Status copy_block_to_page(struct scanner *s,int side) { @@ -4322,11 +4409,10 @@ copy_block_to_page(struct scanner *s,int side) struct transfer * block = &s->block_xfr; struct page * page = &s->pages[side]; int image_height = block->total_bytes / block->line_stride; - int page_height = SCANNER_UNIT_TO_PIX(s->page_height, s->resolution); int page_width = page->image->width_pix; int block_page_stride = block->image->width_bytes * block->image->height; int line_reverse = (side == SIDE_BACK) || (s->model == MODEL_FI60F) || (s->model == MODEL_FI65F); - int i,j,k=0,l=0; + int i,j,k=0; int curr_in_row = s->fullscan.rx_bytes/s->fullscan.width_bytes; int last_out_row = (page->bytes_scanned / page->image->width_bytes) - 1; @@ -4334,7 +4420,7 @@ copy_block_to_page(struct scanner *s,int side) DBG (10, "copy_block_to_page: start\n"); /* skip padding and tl_y */ - if (s->fullscan.rx_bytes + s->block_xfr.rx_bytes < block->line_stride * page->image->y_skip_offset) + if (s->fullscan.rx_bytes + s->block_xfr.rx_bytes <= block->line_stride * page->image->y_skip_offset) { DBG (10, "copy_block_to_page: before the start? %d\n", side); return ret; @@ -4345,25 +4431,8 @@ copy_block_to_page(struct scanner *s,int side) DBG (10, "copy_block_to_page: k start? %d\n", k); } - /* skip trailer */ - if (s->page_height) - { - DBG (10, "copy_block_to_page: ph %d\n", s->page_height); - if (s->fullscan.rx_bytes > block->line_stride * page->image->y_skip_offset + page_height * block->line_stride) - { - DBG (10, "copy_block_to_page: off the end? %d\n", side); - return ret; - } - else if (s->fullscan.rx_bytes + s->block_xfr.rx_bytes - > block->line_stride * page->image->y_skip_offset + page_height * block->line_stride) - { - l = (s->fullscan.rx_bytes + s->block_xfr.rx_bytes) / block->line_stride - - page_height - page->image->y_skip_offset; - } - } - /* loop over all the lines in the block */ - for (i = k; i < image_height-l; i++) + for (i = k; i < image_height; i++) { /* determine source and dest rows (dpi scaling) */ int this_in_row = curr_in_row + i; @@ -4389,13 +4458,15 @@ copy_block_to_page(struct scanner *s,int side) last_out_row = this_out_row; - /* reverse order for back side or FI-60F scanner */ - if (line_reverse) + if (block->mode == MODE_COLOR){ + + /* reverse order for back side or FI-60F scanner */ + if (line_reverse) p_in += (page_width - 1) * 3; - - /* convert all of the pixels in this row */ - for (j = 0; j < page_width; j++) - { + + /* convert all of the pixels in this row */ + for (j = 0; j < page_width; j++) + { unsigned char r, g, b; if (s->model == MODEL_S300 || s->model == MODEL_S1300i) { r = p_in[1]; g = p_in[2]; b = p_in[0]; } @@ -4413,12 +4484,41 @@ copy_block_to_page(struct scanner *s,int side) } else if (s->mode == MODE_LINEART) { - s->dt.buffer[j] = (r + g + b) / 3; /* stores dt temp image buffer and binarize afterword */ + s->dt.buffer[j] = (r + g + b) / 3; /* stores dt temp image buffer and binarize afterward */ } if (line_reverse) p_in -= 3; else p_in += 3; + } + } + + /* grayscale input */ + else{ + unsigned char * p_in = block->image->buffer + (side * block_page_stride) + + (i * block->image->width_bytes) + page->image->x_start_offset; + + /* reverse order for back side or FI-60F scanner */ + if (line_reverse) + p_in += (page_width - 1); + + //memcpy(p_out,p_in,page->image->width_bytes); + + for (j = 0; j < page_width; j++) + { + if (s->mode == MODE_GRAYSCALE) + { + *p_out++ = *p_in; + } + else if (s->mode == MODE_LINEART) + { + s->dt.buffer[j] = *p_in; /* stores dt temp image buffer and binarize afterward */ + } + if (line_reverse) + p_in--; + else + p_in++; + } } /* skip non-transfer pixels in block image buffer */ @@ -4576,13 +4676,13 @@ destroy(struct scanner *s) teardown_buffers(s); if(s->sane.name){ - free(s->sane.name); + free((void *) s->sane.name); } if(s->sane.vendor){ - free(s->sane.vendor); + free((void *) s->sane.vendor); } if(s->sane.model){ - free(s->sane.model); + free((void *) s->sane.model); } free(s); diff --git a/backend/epjitsu.conf.in b/backend/epjitsu.conf.in index 155befc..3ba1c15 100644 --- a/backend/epjitsu.conf.in +++ b/backend/epjitsu.conf.in @@ -61,14 +61,23 @@ usb 0x04c5 0x1156 firmware @DATADIR@/sane/epjitsu/300M_0C00.nal usb 0x04c5 0x117f -# Fujitsu S1100 -firmware @DATADIR@/sane/epjitsu/1100_0B00.nal -usb 0x04c5 0x1200 +# Fujitsu fi-65F +firmware @DATADIR@/sane/epjitsu/65f_0A01.nal +usb 0x04c5 0x11bd # Fujitsu S1300 firmware @DATADIR@/sane/epjitsu/1300_0C26.nal usb 0x04c5 0x11ed +# Fujitsu S1100 +firmware @DATADIR@/sane/epjitsu/1100_0B00.nal +usb 0x04c5 0x1200 + # Fujitsu S1300i firmware @DATADIR@/sane/epjitsu/1300i_0D12.nal usb 0x04c5 0x128d + +# Fujitsu S1100i +firmware @DATADIR@/sane/epjitsu/1100i_0A00.nal +usb 0x04c5 0x1447 + diff --git a/backend/epjitsu.h b/backend/epjitsu.h index 7bb1ccc..6dfaf67 100644 --- a/backend/epjitsu.h +++ b/backend/epjitsu.h @@ -55,6 +55,7 @@ struct image { int width_bytes; int height; int pages; + int mode; int x_res; int y_res; int x_start_offset; @@ -71,6 +72,7 @@ struct transfer { int total_bytes; int rx_bytes; int done; + int mode; int x_res; int y_res; @@ -216,6 +218,7 @@ struct scanner /* the scan struct holds these larger numbers, but image buffer is unused */ struct { int done; + int mode; int x_res; int y_res; int height; @@ -259,12 +262,12 @@ struct scanner int hw_sleep; }; -#define MODEL_NONE 0 -#define MODEL_S300 1 -#define MODEL_FI60F 2 -#define MODEL_S1100 3 -#define MODEL_S1300i 4 -#define MODEL_FI65F 5 +#define MODEL_NONE (1<<0) +#define MODEL_S300 (1<<1) +#define MODEL_FI60F (1<<2) +#define MODEL_S1100 (1<<3) +#define MODEL_S1300i (1<<4) +#define MODEL_FI65F (1<<5) #define USB_COMMAND_TIME 10000 #define USB_DATA_TIME 10000 @@ -378,6 +381,7 @@ static SANE_Status set_window(struct scanner *s, int window); static SANE_Status scan(struct scanner *s); static SANE_Status read_from_scanner(struct scanner *s, struct transfer *tp); +static SANE_Status descramble_raw_gray(struct scanner *s, struct transfer * tp); static SANE_Status descramble_raw(struct scanner *s, struct transfer * tp); static SANE_Status copy_block_to_page(struct scanner *s, int side); static SANE_Status binarize_line(struct scanner *s, unsigned char *lineOut, int width); diff --git a/backend/epson.c b/backend/epson.c index 6b111f2..3fc264f 100644 --- a/backend/epson.c +++ b/backend/epson.c @@ -4232,7 +4232,7 @@ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Epson_Scanner *s = (Epson_Scanner *) handle; - int ndpi, max_x, max_y; + int ndpi; int bytes_per_pixel; DBG (5, "sane_get_parameters()\n"); @@ -4270,8 +4270,6 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) ndpi = s->val[OPT_RESOLUTION].w; - max_x = max_y = 0; - s->params.pixels_per_line = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) / 25.4 * ndpi + 0.5; s->params.lines = @@ -5271,7 +5269,6 @@ sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, int index = 0; SANE_Bool reorder = SANE_FALSE; SANE_Bool needStrangeReorder = SANE_FALSE; - int bytes_to_process = 0; START_READ: DBG (5, "sane_read: begin\n"); @@ -5447,9 +5444,7 @@ START_READ: reorder = SANE_TRUE; } - bytes_to_process = receive (s, s->buf, buf_len, &status); - - /* bytes_to_process = buf_len; */ + receive (s, s->buf, buf_len, &status); if (SANE_STATUS_GOOD != status) { diff --git a/backend/epson2-io.c b/backend/epson2-io.c index 4477963..9d23e2a 100644 --- a/backend/epson2-io.c +++ b/backend/epson2-io.c @@ -113,32 +113,37 @@ ssize_t e2_recv(Epson_Scanner *s, void *buf, ssize_t buf_size, SANE_Status *status) { - ssize_t n = 0; + ssize_t n = buf_size; /* network interface needs to read header back even data is 0.*/ DBG(15, "%s: size = %ld, buf = %p\n", __func__, (long) buf_size, buf); + *status = SANE_STATUS_GOOD; if (s->hw->connection == SANE_EPSON_NET) { n = sanei_epson_net_read(s, buf, buf_size, status); } else if (s->hw->connection == SANE_EPSON_SCSI) { - n = sanei_epson2_scsi_read(s->fd, buf, buf_size, status); + if (buf_size) + n = sanei_epson2_scsi_read(s->fd, buf, buf_size, status); } else if (s->hw->connection == SANE_EPSON_PIO) { - if (buf_size == - (n = sanei_pio_read(s->fd, buf, (size_t) buf_size))) - *status = SANE_STATUS_GOOD; - else - *status = SANE_STATUS_INVAL; + if (buf_size) { + if (buf_size == + (n = sanei_pio_read(s->fd, buf, (size_t) buf_size))) + *status = SANE_STATUS_GOOD; + else + *status = SANE_STATUS_INVAL; + } } else if (s->hw->connection == SANE_EPSON_USB) { /* !!! only report an error if we don't read anything */ - n = buf_size; /* buf_size gets overwritten */ - *status = - sanei_usb_read_bulk(s->fd, (SANE_Byte *) buf, - (size_t *) & n); - r_cmd_count += (n + 63) / 64; /* add # of packets, rounding up */ - DBG(20, "%s: cmd count, r = %d, w = %d\n", - __func__, r_cmd_count, w_cmd_count); - - if (n > 0) - *status = SANE_STATUS_GOOD; + if (n) { + *status = + sanei_usb_read_bulk(s->fd, (SANE_Byte *) buf, + (size_t *) & n); + r_cmd_count += (n + 63) / 64; /* add # of packets, rounding up */ + DBG(20, "%s: cmd count, r = %d, w = %d\n", + __func__, r_cmd_count, w_cmd_count); + + if (n > 0) + *status = SANE_STATUS_GOOD; + } } if (n < buf_size) { @@ -170,18 +175,23 @@ e2_txrx(Epson_Scanner * s, unsigned char *txbuf, size_t txlen, unsigned char *rxbuf, size_t rxlen) { SANE_Status status; + size_t done; - e2_send(s, txbuf, txlen, rxlen, &status); + done = e2_send(s, txbuf, txlen, rxlen, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: tx err, %s\n", __func__, sane_strstatus(status)); return status; } + if (done != txlen) { + DBG(1, "%s: tx err, short write\n", __func__); + return SANE_STATUS_IO_ERROR; + } e2_recv(s, rxbuf, rxlen, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: rx err, %s\n", __func__, sane_strstatus(status)); } - + DBG(1, "%s: eds_recv status, %s\n", __func__, sane_strstatus(status)); return status; } diff --git a/backend/epson2-ops.c b/backend/epson2-ops.c index eac01b0..1ba2292 100644 --- a/backend/epson2-ops.c +++ b/backend/epson2-ops.c @@ -2087,7 +2087,6 @@ e2_block_read(struct Epson_Scanner *s) { SANE_Status status; SANE_Bool reorder = SANE_FALSE; - SANE_Bool needStrangeReorder = SANE_FALSE; START_READ: DBG(18, "%s: begin\n", __func__); @@ -2149,22 +2148,6 @@ e2_block_read(struct Epson_Scanner *s) * are doing this here: */ - /* - * Some scanners (e.g. the Perfection 1640 and GT-2200) seem - * to have the R and G channels swapped. - * The GT-8700 is the Asian version of the Perfection 1640. - * If the scanner name is one of these and the scan mode is - * RGB then swap the colors. - */ - - /* never used, beta testers required */ - needStrangeReorder = - (strstr(s->hw->model, "GT-2200") || - ((strstr(s->hw->model, "1640") - && strstr(s->hw->model, "Perfection")) - || strstr(s->hw->model, "GT-8700"))) - && s->params.format == SANE_FRAME_RGB; - /* * Certain Perfection 1650 also need this re-ordering of the two * color channels. These scanners are identified by the problem diff --git a/backend/epson2.h b/backend/epson2.h index 8650f01..773c7de 100644 --- a/backend/epson2.h +++ b/backend/epson2.h @@ -45,13 +45,6 @@ #include "sane/sanei_backend.h" #include "sane/sanei_debug.h" -#ifdef __GNUC__ -#define __func__ __FUNCTION__ -#else -#define __func__ "(undef)" -/* I cast my vote for C99... :) */ -#endif - #define EPSON2_CONFIG_FILE "epson2.conf" #ifndef PATH_MAX diff --git a/backend/epson2_net.c b/backend/epson2_net.c index 911ce62..4b3e7e9 100644 --- a/backend/epson2_net.c +++ b/backend/epson2_net.c @@ -104,7 +104,7 @@ sanei_epson_net_read(Epson_Scanner *s, unsigned char *buf, ssize_t wanted, size = be32atoh(&header[6]); - DBG(23, "%s: wanted = %lu, available = %lu\n", __FUNCTION__, + DBG(23, "%s: wanted = %lu, available = %lu\n", __func__, (u_long) wanted, (u_long) size); *status = SANE_STATUS_GOOD; @@ -170,7 +170,7 @@ sanei_epson_net_write(Epson_Scanner *s, unsigned int cmd, const unsigned char *b } DBG(24, "%s: cmd = %04x, buf = %p, buf_size = %lu, reply_len = %lu\n", - __FUNCTION__, cmd, buf, (u_long) buf_size, (u_long) reply_len); + __func__, cmd, buf, (u_long) buf_size, (u_long) reply_len); memset(h1, 0x00, 12); memset(h2, 0x00, 8); diff --git a/backend/epson2_scsi.c b/backend/epson2_scsi.c index 89394cd..8e95c6f 100644 --- a/backend/epson2_scsi.c +++ b/backend/epson2_scsi.c @@ -32,7 +32,7 @@ sanei_epson2_scsi_sense_handler(int scsi_fd, if (result[0] && result[0] != 0x70) { DBG(2, "%s: sense code = 0x%02x\n", - __FUNCTION__, result[0]); + __func__, result[0]); return SANE_STATUS_IO_ERROR; } else { return SANE_STATUS_GOOD; diff --git a/backend/epsonds-cmd.c b/backend/epsonds-cmd.c index b91f3f1..9a4db30 100644 --- a/backend/epsonds-cmd.c +++ b/backend/epsonds-cmd.c @@ -21,6 +21,7 @@ #include "epsonds-io.h" #include "epsonds-cmd.h" #include "epsonds-ops.h" +#include "epsonds-net.h" static SANE_Status esci2_parse_block(char *buf, int len, void *userdata, SANE_Status (*cb)(void *userdata, char *token, int len)) @@ -132,49 +133,39 @@ static SANE_Status esci2_cmd(epsonds_scanner* s, { SANE_Status status; unsigned int more; - char rbuf[64]; + char header[13], rbuf[64]; /* add one more byte for header buffer to correct buffer overflow issue,*/ DBG(8, "%s: %4s len %lu, payload len: %lu\n", __func__, cmd, len, plen); - if (len < 12) { - DBG(1, "%s: command is too short (%lu)\n", __func__, len); + memset(header, 0x00, sizeof(header)); + memset(rbuf, 0x00, sizeof(rbuf)); + + // extra safety check, will not happen + if (len != 12) { + DBG(1, "%s: command has wrong size (%lu != 12)\n", __func__, len); return SANE_STATUS_INVAL; } - /* merge the payload size and send the RequestBlock */ - if (payload && plen) { - - sprintf(rbuf, "%4.4sx%07x", cmd, (unsigned int)plen); - - DBG(8, " %s (%lu)\n", rbuf, plen); - - eds_send(s, rbuf, 12, &status); - - } else { - eds_send(s, cmd, len, &status); - } + // merge ParameterBlock size + sprintf(header, "%4.4sx%07x", cmd, (unsigned int)plen); + // send RequestBlock, request immediate response if there's no payload + status = eds_txrx(s, header, len, rbuf, (plen > 0) ? 0 : 64); if (status != SANE_STATUS_GOOD) { return status; } - /* send ParameterBlock */ - if (payload && plen) { + /* send ParameterBlock, request response */ + if (plen) { + + DBG(8, " %12.12s (%lu)\n", header, plen); - eds_send(s, payload, plen, &status); + status = eds_txrx(s, payload, plen, rbuf, 64); if (status != SANE_STATUS_GOOD) { return status; } } - /* receive DataHeaderBlock */ - memset(rbuf, 0x00, sizeof(rbuf)); - - eds_recv(s, rbuf, 64, &status); - if (status != SANE_STATUS_GOOD) { - return status; - } - /* rxbuf holds the DataHeaderBlock, which should be * parsed to know if we need to read more data */ @@ -196,6 +187,10 @@ static SANE_Status esci2_cmd(epsonds_scanner* s, char *pbuf = malloc(more); if (pbuf) { + if (s->hw->connection == SANE_EPSONDS_NET) { + epsonds_net_request_read(s, more); + } + ssize_t read = eds_recv(s, pbuf, more, &status); if (read != more) { } @@ -853,7 +848,7 @@ esci2_img(struct epsonds_scanner *s, SANE_Int *length) return SANE_STATUS_CANCELLED; /* request image data */ - eds_send(s, "IMG x0000000", 12, &status); + eds_send(s, "IMG x0000000", 12, &status, 64); if (status != SANE_STATUS_GOOD) { return status; } @@ -882,6 +877,10 @@ esci2_img(struct epsonds_scanner *s, SANE_Int *length) } /* ALWAYS read image data */ + if (s->hw->connection == SANE_EPSONDS_NET) { + epsonds_net_request_read(s, more); + } + read = eds_recv(s, s->buf, more, &status); if (status != SANE_STATUS_GOOD) { return status; diff --git a/backend/epsonds-io.c b/backend/epsonds-io.c index 28bacfc..e153ad4 100644 --- a/backend/epsonds-io.c +++ b/backend/epsonds-io.c @@ -16,11 +16,19 @@ #include "sane/config.h" #include #include /* sleep */ +#ifdef HAVE_SYS_TYPES_H +#include +#endif #include "epsonds.h" #include "epsonds-io.h" +#include "epsonds-net.h" -size_t eds_send(epsonds_scanner *s, void *buf, size_t length, SANE_Status *status) +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +size_t eds_send(epsonds_scanner *s, void *buf, size_t length, SANE_Status *status, size_t reply_len) { DBG(32, "%s: size = %lu\n", __func__, (u_long) length); @@ -36,7 +44,9 @@ size_t eds_send(epsonds_scanner *s, void *buf, size_t length, SANE_Status *statu } if (s->hw->connection == SANE_EPSONDS_NET) { - /* XXX */ + + return epsonds_net_write(s, 0x2000, buf, length, reply_len, status); + } else if (s->hw->connection == SANE_EPSONDS_USB) { size_t n = length; @@ -55,21 +65,23 @@ size_t eds_send(epsonds_scanner *s, void *buf, size_t length, SANE_Status *statu size_t eds_recv(epsonds_scanner *s, void *buf, size_t length, SANE_Status *status) { - size_t n = 0; + size_t n = length; /* network interface needs to read header back even data is 0.*/ DBG(30, "%s: size = %ld, buf = %p\n", __func__, (long) length, buf); + *status = SANE_STATUS_GOOD; + if (s->hw->connection == SANE_EPSONDS_NET) { - /* XXX */ + n = epsonds_net_read(s, buf, length, status); } else if (s->hw->connection == SANE_EPSONDS_USB) { /* !!! only report an error if we don't read anything */ - - n = length; - *status = sanei_usb_read_bulk(s->fd, (SANE_Byte *)buf, - (size_t *) &n); - if (n > 0) - *status = SANE_STATUS_GOOD; + if (n) { + *status = sanei_usb_read_bulk(s->fd, (SANE_Byte *)buf, + (size_t *) &n); + if (n > 0) + *status = SANE_STATUS_GOOD; + } } if (n < length) { @@ -90,7 +102,7 @@ SANE_Status eds_txrx(epsonds_scanner* s, char *txbuf, size_t txlen, SANE_Status status; size_t done; - done = eds_send(s, txbuf, txlen, &status); + done = eds_send(s, txbuf, txlen, &status, rxlen); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: tx err, %s\n", __func__, sane_strstatus(status)); return status; @@ -147,6 +159,7 @@ SANE_Status eds_fsy(epsonds_scanner *s) SANE_Status eds_fsx(epsonds_scanner *s) { +// SANE_Status status = eds_control(s, "\x1CZ", 2); SANE_Status status = eds_control(s, "\x1CX", 2); if (status == SANE_STATUS_GOOD) { s->locked = 1; diff --git a/backend/epsonds-io.h b/backend/epsonds-io.h index 1a1b2b7..1bb67c6 100644 --- a/backend/epsonds-io.h +++ b/backend/epsonds-io.h @@ -17,7 +17,7 @@ #define USB_TIMEOUT (6 * 1000) #define USB_SHORT_TIMEOUT (1 * 800) -size_t eds_send(epsonds_scanner *s, void *buf, size_t length, SANE_Status *status); +size_t eds_send(epsonds_scanner *s, void *buf, size_t length, SANE_Status *status, size_t reply_len); size_t eds_recv(epsonds_scanner *s, void *buf, size_t length, SANE_Status *status); SANE_Status eds_txrx(epsonds_scanner *s, char *txbuf, size_t txlen, diff --git a/backend/epsonds-jpeg.c b/backend/epsonds-jpeg.c index 76a52cb..62e8bb5 100644 --- a/backend/epsonds-jpeg.c +++ b/backend/epsonds-jpeg.c @@ -13,6 +13,8 @@ #define DEBUG_DECLARE_ONLY +#include "sane/config.h" + #include #include "epsonds.h" @@ -35,12 +37,12 @@ typedef struct epsonds_src_mgr; METHODDEF(void) -jpeg_init_source(j_decompress_ptr UNUSEDARG cinfo) +jpeg_init_source(j_decompress_ptr __sane_unused__ cinfo) { } METHODDEF(void) -jpeg_term_source(j_decompress_ptr UNUSEDARG cinfo) +jpeg_term_source(j_decompress_ptr __sane_unused__ cinfo) { } diff --git a/backend/epsonds-jpeg.h b/backend/epsonds-jpeg.h index c54208e..a804dec 100644 --- a/backend/epsonds-jpeg.h +++ b/backend/epsonds-jpeg.h @@ -11,8 +11,6 @@ * published by the Free Software Foundation, version 2. */ -#define UNUSEDARG __attribute__ ((unused)) - SANE_Status eds_jpeg_start(epsonds_scanner *s); void eds_jpeg_finish(epsonds_scanner *s); SANE_Status eds_jpeg_read_header(epsonds_scanner *s); diff --git a/backend/epsonds-net.c b/backend/epsonds-net.c new file mode 100644 index 0000000..8ea236b --- /dev/null +++ b/backend/epsonds-net.c @@ -0,0 +1,278 @@ +/* + * epsonds-net.c - SANE library for Epson scanners. + * + * Copyright (C) 2006-2016 Tower Technologies + * Author: Alessandro Zummo + * + * This file is part of the SANE package. + * + * 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, version 2. + */ + +#define DEBUG_DECLARE_ONLY + +#include "sane/config.h" + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#include "sane/sane.h" +#include "sane/saneopts.h" +#include "sane/sanei_tcp.h" +#include "sane/sanei_config.h" +#include "sane/sanei_backend.h" + +#include "epsonds.h" +#include "epsonds-net.h" + +#include "byteorder.h" + +#include "sane/sanei_debug.h" + +static int +epsonds_net_read_raw(epsonds_scanner *s, unsigned char *buf, ssize_t wanted, + SANE_Status *status) +{ + int ready, read = -1; + fd_set readable; + struct timeval tv; + + tv.tv_sec = 10; + tv.tv_usec = 0; + + FD_ZERO(&readable); + FD_SET(s->fd, &readable); + + ready = select(s->fd + 1, &readable, NULL, NULL, &tv); + if (ready > 0) { + read = sanei_tcp_read(s->fd, buf, wanted); + } else { + DBG(15, "%s: select failed: %d\n", __func__, ready); + } + + *status = SANE_STATUS_GOOD; + + if (read < wanted) { + *status = SANE_STATUS_IO_ERROR; + } + + return read; +} + +int +epsonds_net_read(epsonds_scanner *s, unsigned char *buf, ssize_t wanted, + SANE_Status * status) +{ + ssize_t size; + ssize_t read = 0; + unsigned char header[12]; + + /* read from buffer, if available */ + if (wanted && s->netptr != s->netbuf) { + DBG(23, "reading %lu from buffer at %p, %lu available\n", + (u_long) wanted, s->netptr, (u_long) s->netlen); + + memcpy(buf, s->netptr, wanted); + read = wanted; + + s->netlen -= wanted; + + if (s->netlen == 0) { + DBG(23, "%s: freeing %p\n", __func__, s->netbuf); + free(s->netbuf); + s->netbuf = s->netptr = NULL; + s->netlen = 0; + } + + return read; + } + + /* receive net header */ + size = epsonds_net_read_raw(s, header, 12, status); + if (size != 12) { + return 0; + } + + if (header[0] != 'I' || header[1] != 'S') { + DBG(1, "header mismatch: %02X %02x\n", header[0], header[1]); + *status = SANE_STATUS_IO_ERROR; + return 0; + } + + // incoming payload size + size = be32atoh(&header[6]); + + DBG(23, "%s: wanted = %lu, available = %lu\n", __func__, + (u_long) wanted, (u_long) size); + + *status = SANE_STATUS_GOOD; + + if (size == wanted) { + + DBG(15, "%s: full read\n", __func__); + + if (size) { + read = epsonds_net_read_raw(s, buf, size, status); + } + + if (s->netbuf) { + free(s->netbuf); + s->netbuf = NULL; + s->netlen = 0; + } + + if (read < 0) { + return 0; + } + + } else if (wanted < size) { + + DBG(23, "%s: long tail\n", __func__); + + read = epsonds_net_read_raw(s, s->netbuf, size, status); + if (read != size) { + return 0; + } + + memcpy(buf, s->netbuf, wanted); + read = wanted; + + free(s->netbuf); + s->netbuf = NULL; + s->netlen = 0; + + } else { + + DBG(23, "%s: partial read\n", __func__); + + read = epsonds_net_read_raw(s, s->netbuf, size, status); + if (read != size) { + return 0; + } + + s->netlen = size - wanted; + s->netptr += wanted; + read = wanted; + + DBG(23, "0,4 %02x %02x\n", s->netbuf[0], s->netbuf[4]); + DBG(23, "storing %lu to buffer at %p, next read at %p, %lu bytes left\n", + (u_long) size, s->netbuf, s->netptr, (u_long) s->netlen); + + memcpy(buf, s->netbuf, wanted); + } + + return read; +} + +SANE_Status +epsonds_net_request_read(epsonds_scanner *s, size_t len) +{ + SANE_Status status; + epsonds_net_write(s, 0x2000, NULL, 0, len, &status); + return status; +} + +int +epsonds_net_write(epsonds_scanner *s, unsigned int cmd, const unsigned char *buf, + size_t buf_size, size_t reply_len, SANE_Status *status) +{ + unsigned char *h1, *h2; + unsigned char *packet = malloc(12 + 8); + + /* XXX check allocation failure */ + + h1 = packet; // packet header + h2 = packet + 12; // data header + + if (reply_len) { + s->netbuf = s->netptr = malloc(reply_len); + s->netlen = reply_len; + DBG(24, "allocated %lu bytes at %p\n", + (u_long) reply_len, s->netbuf); + } + + DBG(24, "%s: cmd = %04x, buf = %p, buf_size = %lu, reply_len = %lu\n", + __func__, cmd, buf, (u_long) buf_size, (u_long) reply_len); + + memset(h1, 0x00, 12); + memset(h2, 0x00, 8); + + h1[0] = 'I'; + h1[1] = 'S'; + + h1[2] = cmd >> 8; // packet type + h1[3] = cmd; // data type + + h1[4] = 0x00; + h1[5] = 0x0C; // data offset + + DBG(24, "H1[0]: %02x %02x %02x %02x\n", h1[0], h1[1], h1[2], h1[3]); + + // 0x20 passthru + // 0x21 job control + + if (buf_size) { + htobe32a(&h1[6], buf_size); + } + + if((cmd >> 8) == 0x20) { + + htobe32a(&h1[6], buf_size + 8); // data size (data header + payload) + + htobe32a(&h2[0], buf_size); // payload size + htobe32a(&h2[4], reply_len); // expected answer size + + DBG(24, "H1[6]: %02x %02x %02x %02x (%lu)\n", h1[6], h1[7], h1[8], h1[9], (u_long) (buf_size + 8)); + DBG(24, "H2[0]: %02x %02x %02x %02x (%lu)\n", h2[0], h2[1], h2[2], h2[3], (u_long) buf_size); + DBG(24, "H2[4]: %02x %02x %02x %02x (%lu)\n", h2[4], h2[5], h2[6], h2[7], (u_long) reply_len); + } + + if ((cmd >> 8) == 0x20 && (buf_size || reply_len)) { + + // send header + data header + sanei_tcp_write(s->fd, packet, 12 + 8); + + } else { + sanei_tcp_write(s->fd, packet, 12); + } + + // send payload + if (buf_size) + sanei_tcp_write(s->fd, buf, buf_size); + + free(packet); + + *status = SANE_STATUS_GOOD; + return buf_size; +} + +SANE_Status +epsonds_net_lock(struct epsonds_scanner *s) +{ + SANE_Status status; + unsigned char buf[7] = "\x01\xa0\x04\x00\x00\x01\x2c"; + + DBG(1, "%s\n", __func__); + + epsonds_net_write(s, 0x2100, buf, 7, 0, &status); + epsonds_net_read(s, buf, 1, &status); + + // buf[0] should be ACK, 0x06 + + return status; +} + +SANE_Status +epsonds_net_unlock(struct epsonds_scanner *s) +{ + SANE_Status status; + + DBG(1, "%s\n", __func__); + + epsonds_net_write(s, 0x2101, NULL, 0, 0, &status); +/* epsonds_net_read(s, buf, 1, &status); */ + return status; +} diff --git a/backend/epsonds-net.h b/backend/epsonds-net.h new file mode 100644 index 0000000..f7b173e --- /dev/null +++ b/backend/epsonds-net.h @@ -0,0 +1,16 @@ +#ifndef _EPSONDS_NET_H_ +#define _EPSONDS_NET_H_ + +#include +#include "../include/sane/sane.h" + +extern int epsonds_net_read(struct epsonds_scanner *s, unsigned char *buf, ssize_t buf_size, + SANE_Status *status); +extern int epsonds_net_write(struct epsonds_scanner *s, unsigned int cmd, const unsigned char *buf, + size_t buf_size, size_t reply_len, + SANE_Status *status); +extern SANE_Status epsonds_net_lock(struct epsonds_scanner *s); +extern SANE_Status epsonds_net_unlock(struct epsonds_scanner *s); +extern SANE_Status epsonds_net_request_read(epsonds_scanner *s, size_t len); + +#endif diff --git a/backend/epsonds-ops.c b/backend/epsonds-ops.c index 403cd58..f7a07fb 100644 --- a/backend/epsonds-ops.c +++ b/backend/epsonds-ops.c @@ -72,6 +72,18 @@ eds_dev_post_init(struct epsonds_device *dev) return SANE_STATUS_GOOD; } +SANE_Bool +eds_is_model(epsonds_device *dev, const char *model) +{ + if (dev->model == NULL) + return SANE_FALSE; + + if (strncmp(dev->model, model, strlen(model)) == 0) + return SANE_TRUE; + + return SANE_FALSE; +} + SANE_Status eds_add_resolution(epsonds_device *dev, int r) { @@ -199,6 +211,12 @@ eds_init_parameters(epsonds_scanner *s) s->dummy = 0; + /* setup depth according to our mode table */ + if (mode_params[s->val[OPT_MODE].w].depth == 1) + s->params.depth = 1; + else + s->params.depth = s->val[OPT_DEPTH].w; + dpi = s->val[OPT_RESOLUTION].w; if (SANE_UNFIX(s->val[OPT_BR_Y].w) == 0 || @@ -246,11 +264,6 @@ eds_init_parameters(epsonds_scanner *s) * The default color depth is stored in mode_params.depth: */ - if (mode_params[s->val[OPT_MODE].w].depth == 1) - s->params.depth = 1; - else - s->params.depth = s->val[OPT_DEPTH].w; - /* this works because it can only be set to 1, 8 or 16 */ bytes_per_pixel = s->params.depth / 8; if (s->params.depth % 8) { /* just in case ... */ diff --git a/backend/epsonds-ops.h b/backend/epsonds-ops.h index 3f45393..ac5e71b 100644 --- a/backend/epsonds-ops.h +++ b/backend/epsonds-ops.h @@ -11,11 +11,11 @@ * published by the Free Software Foundation, version 2. */ -#define e2_model(s,m) e2_dev_model((s)->hw,(m)) - extern void eds_dev_init(epsonds_device *dev); extern SANE_Status eds_dev_post_init(struct epsonds_device *dev); +extern SANE_Bool eds_is_model(epsonds_device *dev, const char *model); + extern SANE_Status eds_add_resolution(epsonds_device *dev, int r); extern SANE_Status eds_set_resolution_range(epsonds_device *dev, int min, int max); extern void eds_set_fbf_area(epsonds_device *dev, int x, int y, int unit); diff --git a/backend/epsonds.c b/backend/epsonds.c index 2f85312..218e08c 100644 --- a/backend/epsonds.c +++ b/backend/epsonds.c @@ -12,8 +12,8 @@ */ #define EPSONDS_VERSION 1 -#define EPSONDS_REVISION 0 -#define EPSONDS_BUILD 35 +#define EPSONDS_REVISION 1 +#define EPSONDS_BUILD 0 /* debugging levels: * @@ -41,9 +41,12 @@ #include "sane/config.h" #include +#include #include "sane/saneopts.h" #include "sane/sanei_config.h" +#include "sane/sanei_tcp.h" +#include "sane/sanei_udp.h" #include "epsonds.h" #include "epsonds-usb.h" @@ -51,6 +54,8 @@ #include "epsonds-cmd.h" #include "epsonds-ops.h" #include "epsonds-jpeg.h" +#include "epsonds-net.h" + /* * Definition of the mode_param struct, that is used to @@ -115,6 +120,7 @@ max_string_size(const SANE_String_Const strings[]) } static SANE_Status attach_one_usb(SANE_String_Const devname); +static SANE_Status attach_one_net(SANE_String_Const devname); static void print_params(const SANE_Parameters params) @@ -140,7 +146,10 @@ close_scanner(epsonds_scanner *s) esci2_fin(s); } - if (s->hw->connection == SANE_EPSONDS_USB) { + if (s->hw->connection == SANE_EPSONDS_NET) { + epsonds_net_unlock(s); + sanei_tcp_close(s->fd); + } else if (s->hw->connection == SANE_EPSONDS_USB) { sanei_usb_close(s->fd); } @@ -154,6 +163,49 @@ free: DBG(7, "%s: ZZZ\n", __func__); } +static void +e2_network_discovery(void) +{ + fd_set rfds; + int fd, len; + SANE_Status status; + + char *ip, *query = "EPSONP\x00\xff\x00\x00\x00\x00\x00\x00\x00"; + unsigned char buf[76]; + + struct timeval to; + + status = sanei_udp_open_broadcast(&fd); + if (status != SANE_STATUS_GOOD) + return; + + sanei_udp_write_broadcast(fd, 3289, (unsigned char *) query, 15); + + DBG(5, "%s, sent discovery packet\n", __func__); + + to.tv_sec = 1; + to.tv_usec = 0; + + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + + sanei_udp_set_nonblock(fd, SANE_TRUE); + while (select(fd + 1, &rfds, NULL, NULL, &to) > 0) { + if ((len = sanei_udp_recvfrom(fd, buf, 76, &ip)) == 76) { + DBG(5, " response from %s\n", ip); + + /* minimal check, protocol unknown */ + if (strncmp((char *) buf, "EPSON", 5) == 0) + attach_one_net(ip); + } + } + + DBG(5, "%s, end\n", __func__); + + sanei_udp_close(fd); +} + + static SANE_Status open_scanner(epsonds_scanner *s) { @@ -166,10 +218,59 @@ open_scanner(epsonds_scanner *s) return SANE_STATUS_GOOD; /* no need to open the scanner */ } - if (s->hw->connection == SANE_EPSONDS_USB) { + if (s->hw->connection == SANE_EPSONDS_NET) { + unsigned char buf[5]; + + /* device name has the form net:ipaddr */ + status = sanei_tcp_open(&s->hw->sane.name[4], 1865, &s->fd); + if (status == SANE_STATUS_GOOD) { + + ssize_t read; + struct timeval tv; + + tv.tv_sec = 5; + tv.tv_usec = 0; + + setsockopt(s->fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); + + s->netlen = 0; + + DBG(32, "awaiting welcome message\n"); + + /* the scanner sends a kind of welcome msg */ + // XXX check command type, answer to connect is 0x80 + read = eds_recv(s, buf, 3, &status); + if (read != 3) { + sanei_tcp_close(s->fd); + s->fd = -1; + return SANE_STATUS_IO_ERROR; + } + + DBG(32, "welcome message received, locking the scanner...\n"); + + /* lock the scanner for use by sane */ + status = epsonds_net_lock(s); + if (status != SANE_STATUS_GOOD) { + DBG(1, "%s cannot lock scanner: %s\n", s->hw->sane.name, + sane_strstatus(status)); + + sanei_tcp_close(s->fd); + s->fd = -1; + + return status; + } + + DBG(32, "scanner locked\n"); + } + + } else if (s->hw->connection == SANE_EPSONDS_USB) { status = sanei_usb_open(s->hw->sane.name, &s->fd); - sanei_usb_set_timeout(USB_TIMEOUT); + + if (status == SANE_STATUS_GOOD) { + sanei_usb_set_timeout(USB_TIMEOUT); + sanei_usb_clear_halt(s->fd); + } } else { DBG(1, "unknown connection type: %d\n", s->hw->connection); @@ -220,12 +321,20 @@ device_detect(const char *name, int type, SANE_Status *status) struct epsonds_scanner *s; struct epsonds_device *dev; - DBG(1, "%s\n", __func__); + DBG(1, "%s, %s, type: %d\n", __func__, name, type); /* try to find the device in our list */ for (dev = first_dev; dev; dev = dev->next) { + if (strcmp(dev->sane.name, name) == 0) { + DBG(1, " found cached device\n"); + + // the device might have been just probed, sleep a bit. + if (dev->connection == SANE_EPSONDS_NET) { + sleep(1); + } + return scanner_create(dev, status); } } @@ -250,8 +359,9 @@ device_detect(const char *name, int type, SANE_Status *status) dev->connection = type; dev->model = strdup("(undetermined)"); + dev->name = strdup(name); - dev->sane.name = name; + dev->sane.name = dev->name; dev->sane.vendor = "Epson"; dev->sane.model = dev->model; dev->sane.type = "ESC/I-2"; @@ -283,11 +393,11 @@ device_detect(const char *name, int type, SANE_Status *status) if (*status != SANE_STATUS_GOOD) goto close; - /* assume 1 and 8 bit are always supported */ + // assume 1 and 8 bit are always supported eds_add_depth(s->hw, 1); eds_add_depth(s->hw, 8); - /* setup area according to available options */ + // setup area according to available options if (s->hw->has_fb) { dev->x_range = &dev->fbf_x_range; @@ -349,6 +459,19 @@ attach_one_usb(const char *dev) return attach(dev, SANE_EPSONDS_USB); } +static SANE_Status +attach_one_net(const char *dev) +{ + char name[39 + 4]; + + DBG(7, "%s: dev = %s\n", __func__, dev); + + strcpy(name, "net:"); + strcat(name, dev); + return attach(name, SANE_EPSONDS_NET); +} + + static SANE_Status attach_one_config(SANEI_Config __sane_unused__ *config, const char *line) { @@ -380,6 +503,16 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line) epsonds_usb_product_ids[i], attach_one_usb); } + } else if (strncmp(line, "net", 3) == 0) { + + /* remove the "net" sub string */ + const char *name = sanei_config_skip_whitespace(line + 3); + + if (strncmp(name, "autodiscovery", 13) == 0) + e2_network_discovery(); + else + attach_one_net(name); + } else { DBG(0, "unable to parse config line: %s\n", line); } @@ -669,7 +802,11 @@ sane_open(SANE_String_Const name, SANE_Handle *handle) } else { - if (strncmp(name, "libusb:", 7) == 0) { + if (strncmp(name, "net:", 4) == 0) { + s = device_detect(name, SANE_EPSONDS_NET, &status); + if (s == NULL) + return status; + } else if (strncmp(name, "libusb:", 7) == 0) { s = device_detect(name, SANE_EPSONDS_USB, &status); if (s == NULL) return status; @@ -1041,7 +1178,7 @@ SANE_Status sane_start(SANE_Handle handle) { epsonds_scanner *s = (epsonds_scanner *)handle; - char buf[64]; + char buf[65]; /* add one more byte to correct buffer overflow issue */ char cmd[100]; /* take care not to overflow */ SANE_Status status = 0; @@ -1112,10 +1249,17 @@ sane_start(SANE_Handle handle) s->val[OPT_ADF_MODE].w ? "DPLX" : "", s->val[OPT_ADF_SKEW].w ? "SKEW" : ""); - if (s->hw->adf_has_dfd == 2) { - strcat(buf, "DFL2"); - } else if (s->hw->adf_has_dfd == 1) { - strcat(buf, "DFL1"); + /* it seems that DFL only works in duplex mode, but it's + * also required to be enabled or duplex will be rejected. + */ + + if (s->val[OPT_ADF_MODE].w) { + + if (s->hw->adf_has_dfd == 2) { + strcat(buf, "DFL2"); + } else if (s->hw->adf_has_dfd == 1) { + strcat(buf, "DFL1"); + } } } else if (strcmp(source_list[s->val[OPT_SOURCE].w], FBF_STR) == 0) { @@ -1148,9 +1292,9 @@ sane_start(SANE_Handle handle) /* resolution (RSMi not always supported) */ if (s->val[OPT_RESOLUTION].w > 999) { - sprintf(buf, "#RSMi%07d", s->val[OPT_RESOLUTION].w); + sprintf(buf, "#RSMi%07d#RSSi%07d", s->val[OPT_RESOLUTION].w, s->val[OPT_RESOLUTION].w); } else { - sprintf(buf, "#RSMd%03d", s->val[OPT_RESOLUTION].w); + sprintf(buf, "#RSMd%03d#RSSd%03d", s->val[OPT_RESOLUTION].w, s->val[OPT_RESOLUTION].w); } strcat(cmd, buf); diff --git a/backend/epsonds.conf.in b/backend/epsonds.conf.in index 23dc461..b8b3623 100644 --- a/backend/epsonds.conf.in +++ b/backend/epsonds.conf.in @@ -10,3 +10,7 @@ usb # e.g.: # usb 0x4b8 0x14c +# Network +# +# net 192.168.1.123 +net autodiscovery diff --git a/backend/epsonds.h b/backend/epsonds.h index 024773b..0427ef3 100644 --- a/backend/epsonds.h +++ b/backend/epsonds.h @@ -43,13 +43,6 @@ #include "sane/sanei_usb.h" #include "sane/sanei_jpeg.h" -#ifdef __GNUC__ -#define __func__ __FUNCTION__ -#else -#define __func__ "(undef)" -/* I cast my vote for C99... :) */ -#endif - #define EPSONDS_CONFIG_FILE "epsonds.conf" #ifndef PATH_MAX @@ -94,7 +87,7 @@ typedef enum { /* hardware connection to the scanner */ SANE_EPSONDS_NODEV, /* default, no HW specified yet */ SANE_EPSONDS_USB, /* USB interface */ - SANE_EPSONDS_NET /* network interface (unsupported)*/ + SANE_EPSONDS_NET /* network interface */ } epsonds_conn_type; /* hardware description */ @@ -180,6 +173,10 @@ struct epsonds_scanner struct jpeg_decompress_struct jpeg_cinfo; struct jpeg_error_mgr jpeg_err; SANE_Bool jpeg_header_seen; + + /* network buffers */ + unsigned char *netbuf, *netptr; + size_t netlen; }; typedef struct epsonds_scanner epsonds_scanner; diff --git a/backend/fujitsu-scsi.h b/backend/fujitsu-scsi.h index de6652c..42598cb 100644 --- a/backend/fujitsu-scsi.h +++ b/backend/fujitsu-scsi.h @@ -377,6 +377,10 @@ putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) #define get_IN_read_size(in) getbitfield(in+0x78, 1, 6) #define get_IN_start_end_ms(in) getbitfield(in+0x78, 1, 5) +#define get_IN_battery(in) getbitfield(in+0x79, 1, 7) +#define get_IN_battery_save(in) getbitfield(in+0x79, 1, 6) +#define get_IN_op_reverse(in) getbitfield(in+0x79, 1, 1) + #define get_IN_op_halt(in) getbitfield(in+0x7a, 1, 7) /* some scanners need evpd inquiry data manipulated */ @@ -616,12 +620,13 @@ putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) #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_gamma_function 0x03 #define S_datatype_lut_data 0x83 +#define S_datatype_lut_dropout 0x84 #define S_datatype_jpg_q_table 0x88 #define S_datatype_endorser_data 0x90 +#define S_datatype_sendto_name 0xa0 /*#define S_EX_datatype_lut 0x01 #define S_EX_datatype_shading_data 0xa0 #define S_user_reg_gamma 0xc0 @@ -747,6 +752,8 @@ putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) #define GHS_data_len 12 #define get_GHS_top(in) getbitfield(in+0x02, 1, 7) +#define get_GHS_fedalm(in) getbitfield(in+0x02, 1, 5) +#define get_GHS_adjalm(in) getbitfield(in+0x02, 1, 4) #define get_GHS_A3(in) getbitfield(in+0x02, 1, 3) #define get_GHS_B4(in) getbitfield(in+0x02, 1, 2) #define get_GHS_A4(in) getbitfield(in+0x02, 1, 1) @@ -762,12 +769,14 @@ putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) #define get_GHS_sleep(in) getbitfield(in+0x04, 1, 7) #define get_GHS_clean(in) getbitfield(in+0x04, 1, 6) +#define get_GHS_scan_sw_long(in) getbitfield(in+0x04, 1, 5) +#define get_GHS_hpos(in) getbitfield(in+0x04, 1, 4) #define get_GHS_send_sw(in) getbitfield(in+0x04, 1, 2) #define get_GHS_manual_feed(in) getbitfield(in+0x04, 1, 1) #define get_GHS_scan_sw(in) getbitfield(in+0x04, 1, 0) #define get_GHS_picalm(in) getbitfield(in+0x05, 1, 7) -#define get_GHS_fadalm(in) getbitfield(in+0x05, 1, 6) +#define get_GHS_padalm(in) getbitfield(in+0x05, 1, 6) #define get_GHS_brkalm(in) getbitfield(in+0x05, 1, 5) #define get_GHS_sepalm(in) getbitfield(in+0x05, 1, 4) #define get_GHS_function(in) getbitfield(in+0x05, 0x0f, 0) @@ -783,10 +792,34 @@ putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) #define get_GHS_error_code(in) in[0x07] -#define get_GHS_skew_angle(in) getnbyte(in+0x08, 2) +#define get_GHS_skew_angle(in) in[0x09] #define get_GHS_ink_remain(in) in[0x0a] +#define get_GHS_lang_code(in) getnbyte(in+0x0c, 2) + +#define get_GHS_adjalm_fed(in) getbitfield(in+0x0e, 1, 7) +#define get_GHS_non_sep(in) getbitfield(in+0x0e, 1, 4) +#define get_GHS_ext_sendto(in) getbitfield(in+0x0e, 1, 2) +#define get_GHS_rq_hldimg(in) getbitfield(in+0x0e, 1, 1) +#define get_GHS_pacnt(in) getbitfield(in+0x0e, 1, 0) + +#define get_GHS_wifi_sw(in) getbitfield(in+0x10, 1, 7) +#define get_GHS_w_use(in) getbitfield(in+0x10, 1, 6) +#define get_GHS_w_use2(in) getbitfield(in+0x10, 1, 5) +#define get_GHS_w_use3(in) getbitfield(in+0x10, 1, 4) +#define get_GHS_w_use4(in) getbitfield(in+0x10, 1, 3) + +#define get_GHS_battery(in) getbitfield(in+0x11, 1, 7) +#define get_GHS_btr_charge(in) getbitfield(in+0x11, 1, 6) +#define get_GHS_btr_chg_tmp_stp(in) getbitfield(in+0x11, 1, 5) +#define get_GHS_ibtr_ene_sav(in) getbitfield(in+0x11, 1, 4) +#define get_GHS_fngr_caut(in) getbitfield(in+0x11, 1, 2) +#define get_GHS_trnpg_l(in) getbitfield(in+0x11, 1, 1) +#define get_GHS_trnpg_r(in) getbitfield(in+0x11, 1, 0) + +#define get_GHS_btr_power(in) in[0x12] + /* ==================================================================== */ /* SCANNER_CONTROL */ #define SCANNER_CONTROL_code 0xf1 @@ -807,6 +840,12 @@ putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) #define SC_function_eject_complete 0x0a #define SC_function_manual_feed 0x0c +/* used with SC_function_panel */ +#define set_SC_led_eb(icb, val) setbitfield(icb + 5, 1, 7, val) +#define set_SC_led(icb, val) setbitfield(icb + 5, 1, 6, val) +#define set_SC_fcno_eb(icb, val) setbitfield(icb + 5, 1, 4, val) +#define set_SC_fcno(icb, val) setbitfield(icb + 5, 0xf, 0, val) + #define set_SC_ric_dtq(sb, val) sb[2] = val #define set_SC_ric_len(sb, val) putnbyte(sb + 0x06, val, 3) @@ -1024,12 +1063,12 @@ putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) /* DTC also called Auto-I mode?*/ /*warning: filtering uses inverse logic*/ -#define set_WD_filtering(sb, val) setbitfield(sb + 0x2f, 1, 7, val) -#define get_WD_filtering(sb) getbitfield(sb + 0x2f, 1, 7) +#define set_WD_filtering(sb, val) setbitfield(sb + 0x2f, 1, 7, !val) +#define get_WD_filtering(sb) !getbitfield(sb + 0x2f, 1, 7) /*warning: smoothing uses inverse logic*/ -#define set_WD_smoothing(sb, val) setbitfield(sb + 0x2f, 3, 5, val) -#define get_WD_smoothing(sb) getbitfield(sb + 0x2f, 3, 5) +#define set_WD_smoothing(sb, val) setbitfield(sb + 0x2f, 3, 5, !val) +#define get_WD_smoothing(sb) !getbitfield(sb + 0x2f, 3, 5) #define set_WD_gamma_curve(sb, val) setbitfield(sb + 0x2f, 3, 3, val) #define get_WD_gamma_curve(sb) getbitfield(sb + 0x2f, 3, 3) diff --git a/backend/fujitsu.c b/backend/fujitsu.c index 9fddb1c..433f75a 100644 --- a/backend/fujitsu.c +++ b/backend/fujitsu.c @@ -6,7 +6,7 @@ Copyright (C) 2000 Randolph Bentson Copyright (C) 2001 Frederik Ramm Copyright (C) 2001-2004 Oliver Schirrmeister - Copyright (C) 2003-2014 m. allan noah + Copyright (C) 2003-2016 m. allan noah JPEG output and low memory usage support funded by: Archivista GmbH, www.archivista.ch @@ -574,9 +574,32 @@ v126 2015-08-23, MAN - initial support for iX100 - add late_lut support for iX500/iX100 - v127 2015-08-25, MAN + v127 2015-08-25, MAN (SANE 1.0.25) - separate iX100 from iX500 settings - iX100 has gray and lineart + v128 2015-11-08, MAN + - do not ask fi-4340 for serial number + v129 2015-11-21, MAN + - br_x and br_y locked to page_width/height until changed + v130 2016-02-23, MAN + - run init_model before init_ms so some scanners can override + - set all M309x and M409x scanners s->broken_diag_serial = 1 + v131 2016-06-06, MAN + - hide compression-arg option when jpeg disabled + - add Send/SC/GHS macros for recent scanners + - add initial support for fi-74x0 + - add initial support for fi-7030 + - set has_MS_lamp=0 for fi-71x0 + - add I18N macros to all option titles and descriptions + v132 2016-10-07, MAN + - remove ipc_mode option and variables + - set ipc mode based on other options + - cleanup inverted logic DTC options + - fixes threshold option reported in #315069 + v133 2017-04-08, MAN + - initial support for fi-7600/7700 + - autodetect various double feed capabilities using VPD + - call send_lut if we are using a downloaded gamma table SANE FLOW DIAGRAM @@ -626,7 +649,7 @@ #include "fujitsu.h" #define DEBUG 1 -#define BUILD 127 +#define BUILD 133 /* values for SANE_DEBUG_FUJITSU env var: - errors 5 @@ -990,22 +1013,22 @@ attach_one (const char *device_name, int connType) return ret; } - /* see what mode pages device supports */ - ret = init_ms (s); + /* clean up the scanner struct based on model */ + /* this is the only piece of model specific code */ + ret = init_model (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); - DBG (5, "attach_one: ms failed\n"); + DBG (5, "attach_one: model failed\n"); return ret; } - /* clean up the scanner struct based on model */ - /* this is the only piece of model specific code */ - ret = init_model (s); + /* see what mode pages device supports */ + ret = init_ms (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); - DBG (5, "attach_one: model failed\n"); + DBG (5, "attach_one: ms failed\n"); return ret; } @@ -1682,6 +1705,9 @@ init_vpd (struct fujitsu *s) DBG (15, " skew check: %d\n", get_IN_skew_check(in)); DBG (15, " new feed roller: %d\n", get_IN_new_fd_roll(in)); + + s->has_adv_paper_prot = get_IN_paper_prot_2(in); + DBG (15, " paper protection: %d\n", s->has_adv_paper_prot); } if (get_IN_page_length (in) > 0x70-5) { @@ -1689,7 +1715,10 @@ init_vpd (struct fujitsu *s) DBG (15, " paper count: %d\n", get_IN_paper_count(in)); DBG (15, " paper number: %d\n", get_IN_paper_number(in)); DBG (15, " ext send to: %d\n", get_IN_ext_send_to(in)); - DBG (15, " staple det: %d\n", get_IN_staple_det(in)); + + s->has_staple_detect = get_IN_staple_det(in); + DBG (15, " staple det: %d\n", s->has_staple_detect); + DBG (15, " pause host: %d\n", get_IN_pause_host(in)); DBG (15, " pause panel: %d\n", get_IN_pause_panel(in)); DBG (15, " pause conf: %d\n", get_IN_pause_conf(in)); @@ -1701,7 +1730,9 @@ init_vpd (struct fujitsu *s) DBG (15, " imprint chk b: %d\n", get_IN_imprint_chk_b(in)); DBG (15, " imprint chk f: %d\n", get_IN_imprint_chk_f(in)); DBG (15, " force w bg: %d\n", get_IN_force_w_bg(in)); - DBG (15, " mf recover lvl: %d\n", get_IN_mf_recover_lvl(in)); + + s->has_df_recovery = get_IN_mf_recover_lvl(in); + DBG (15, " mf recover lvl: %d\n", s->has_df_recovery); DBG (15, " first read time: %d\n", get_IN_first_read_time(in)); DBG (15, " div scanning: %d\n", get_IN_div_scanning(in)); @@ -1720,7 +1751,7 @@ init_vpd (struct fujitsu *s) DBG (15, " sync next feed: %d\n", get_IN_sync_next_feed(in)); s->has_op_halt = get_IN_op_halt(in); - DBG (15, " object postion halt: %d\n", s->has_op_halt); + DBG (15, " object position halt: %d\n", s->has_op_halt); } ret = SANE_STATUS_GOOD; @@ -2014,19 +2045,12 @@ init_model (struct fujitsu *s) /* if scanner has built-in gamma tables, we use the first one (0) */ /* otherwise, we use the first downloaded one (0x80) */ - /* note that you may NOT need to send the table to use it? */ + /* note that you may NOT need to send the table to use it, */ + /* the scanner will fall back to the brightness/contrast LUT */ if (!s->num_internal_gamma && s->num_download_gamma){ s->window_gamma = 0x80; } - /* older scanners would enable their highest */ - /* IPC mode by default. Newer scanners don't, */ - /* so we go ahead and turn it on. */ - if (s->has_sdtc) - s->ipc_mode = WD_ipc_SDTC; - else if (s->has_dtc) - s->ipc_mode = WD_ipc_DTC; - /* endorser type tells string length (among other things) */ if(s->has_endorser_b){ /*old-style is 40 bytes*/ @@ -2141,6 +2165,9 @@ init_model (struct fujitsu *s) else if ( strstr (s->model_name, "M309") || strstr (s->model_name, "M409")){ + /* weirdness */ + s->broken_diag_serial = 1; + /* lies */ s->adbits = 8; } @@ -2160,7 +2187,8 @@ init_model (struct fujitsu *s) s->max_y_fb = 14032; } - else if (strstr (s->model_name, "fi-4750") ) { + else if (strstr (s->model_name,"fi-4340") + || strstr (s->model_name, "fi-4750") ) { /* weirdness */ s->broken_diag_serial = 1; } @@ -2265,10 +2293,8 @@ init_model (struct fujitsu *s) } else if (strstr (s->model_name,"fi-6800") - || strstr (s->model_name,"fi-5900")){ /* guessing this scanner too */ - /* missing from vpd */ - s->has_staple_detect=1; /* may not actually work? */ - s->has_df_recovery=1; + || strstr (s->model_name,"fi-5900")){ + /* do not need overrides */ } else if (strstr (s->model_name,"iX500")){ @@ -2316,6 +2342,8 @@ init_model (struct fujitsu *s) else if (strstr (s->model_name,"fi-7180") || strstr (s->model_name,"fi-7160")){ + /* locks up scanner if we try to auto detect */ + s->has_MS_lamp = 0; /* weirdness */ /* these machines have longer max paper at lower res */ @@ -2325,10 +2353,6 @@ init_model (struct fujitsu *s) s->max_y_by_res[2].len = 260268; s->max_y_by_res[3].res = 200; s->max_y_by_res[3].len = 266268; - - /* missing from vpd */ - s->has_df_recovery=1; - s->has_adv_paper_prot=1; } else if (strstr (s->model_name,"fi-7280") @@ -2344,12 +2368,48 @@ init_model (struct fujitsu *s) s->max_y_by_res[3].len = 266268; /* missing from vpd */ - s->has_df_recovery=1; - s->has_adv_paper_prot=1; s->max_x_fb = 10764; s->max_y_fb = 14032; /* some scanners can be slightly more? */ } + else if (strstr (s->model_name,"fi-7480") + || strstr (s->model_name,"fi-7460")){ + + /* weirdness */ + /* these machines have longer max paper at lower res */ + s->max_y_by_res[1].res = 400; + s->max_y_by_res[1].len = 194268; + s->max_y_by_res[2].res = 300; + s->max_y_by_res[2].len = 260268; + s->max_y_by_res[3].res = 200; + s->max_y_by_res[3].len = 266268; + } + + else if (strstr (s->model_name,"fi-7030")){ + + /* weirdness */ + /* these machines have longer max paper at lower res */ + s->max_y_by_res[1].res = 400; + s->max_y_by_res[1].len = 192000; + s->max_y_by_res[2].res = 300; + s->max_y_by_res[2].len = 258000; + s->max_y_by_res[3].res = 200; + s->max_y_by_res[3].len = 264000; + } + + else if (strstr (s->model_name,"fi-7700") + || strstr (s->model_name,"fi-7600")){ + + /* weirdness */ + /* these machines have longer max paper at lower res */ + s->max_y_by_res[1].res = 400; + s->max_y_by_res[1].len = 192000; + s->max_y_by_res[2].res = 300; + s->max_y_by_res[2].len = 258000; + s->max_y_by_res[3].res = 200; + s->max_y_by_res[3].len = 264000; + } + DBG (10, "init_model: finish\n"); return SANE_STATUS_GOOD; @@ -2439,11 +2499,6 @@ init_user (struct fujitsu *s) s->u_endorser_dir=DIR_TTB; strcpy((char *)s->u_endorser_string,"%05ud"); - /* inverted logic ipc settings */ - s->noise_removal = 1; - s->bp_filter = 1; - s->smoothing = 1; - /* more recent machines default to this being 'on', * * which causes the scanner to ingest multiple pages * * even when the user only wants one */ @@ -3039,8 +3094,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /* gamma */ if(option==OPT_GAMMA){ opt->name = "gamma"; - opt->title = "Gamma function exponent"; - opt->desc = "Changes intensity of midtones"; + opt->title = SANE_I18N ("Gamma function exponent"); + opt->desc = SANE_I18N ("Changes intensity of midtones"); opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -3089,8 +3144,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /* =============== common ipc params ================================ */ if(option==OPT_RIF){ opt->name = "rif"; - opt->title = "RIF"; - opt->desc = "Reverse image format"; + opt->title = SANE_I18N ("RIF"); + opt->desc = SANE_I18N ("Reverse image format"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_rif) @@ -3107,8 +3162,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->ht_type_list[i]=NULL; opt->name = "ht-type"; - opt->title = "Halftone type"; - opt->desc = "Control type of halftone filter"; + opt->title = SANE_I18N ("Halftone type"); + opt->desc = SANE_I18N ("Control type of halftone filter"); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; @@ -3128,8 +3183,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_HT_PATTERN){ opt->name = "ht-pattern"; - opt->title = "Halftone pattern"; - opt->desc = "Control pattern of halftone filter"; + opt->title = SANE_I18N ("Halftone pattern"); + opt->desc = SANE_I18N ("Control pattern of halftone filter"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; @@ -3151,8 +3206,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_OUTLINE){ opt->name = "outline"; - opt->title = "Outline"; - opt->desc = "Perform outline extraction"; + opt->title = SANE_I18N ("Outline"); + opt->desc = SANE_I18N ("Perform outline extraction"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_outline) @@ -3163,8 +3218,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_EMPHASIS){ opt->name = "emphasis"; - opt->title = "Emphasis"; - opt->desc = "Negative to smooth or positive to sharpen image"; + opt->title = SANE_I18N ("Emphasis"); + opt->desc = SANE_I18N ("Negative to smooth or positive to sharpen image"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; @@ -3182,8 +3237,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_SEPARATION){ opt->name = "separation"; - opt->title = "Separation"; - opt->desc = "Enable automatic separation of image and text"; + opt->title = SANE_I18N ("Separation"); + opt->desc = SANE_I18N ("Enable automatic separation of image and text"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_autosep) @@ -3194,8 +3249,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_MIRRORING){ opt->name = "mirroring"; - opt->title = "Mirroring"; - opt->desc = "Reflect output image horizontally"; + opt->title = SANE_I18N ("Mirroring"); + opt->desc = SANE_I18N ("Reflect output image horizontally"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_mirroring) @@ -3212,8 +3267,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->wl_follow_list[i]=NULL; opt->name = "wl-follow"; - opt->title = "White level follower"; - opt->desc = "Control white level follower"; + opt->title = SANE_I18N ("White level follower"); + opt->desc = SANE_I18N ("Control white level follower"); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; @@ -3227,50 +3282,18 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) opt->cap = SANE_CAP_INACTIVE; } - if(option==OPT_IPC_MODE){ - i=0; - s->ipc_mode_list[i++]=STRING_DEFAULT; - if(s->has_dtc){ - s->ipc_mode_list[i++]=STRING_DTC; - } - if(s->has_sdtc){ - s->ipc_mode_list[i++]=STRING_SDTC; - } - s->ipc_mode_list[i]=NULL; - - opt->name = "ipc-mode"; - opt->title = "IPC mode"; - opt->desc = "Image processing mode, enables additional options"; - opt->type = SANE_TYPE_STRING; - opt->unit = SANE_UNIT_NONE; - - opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; - opt->constraint.string_list = s->ipc_mode_list; - opt->size = maxStringSize (opt->constraint.string_list); - - if ( i > 2 ){ - opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if(s->s_mode != MODE_HALFTONE && s->s_mode != MODE_LINEART){ - opt->cap |= SANE_CAP_INACTIVE; - } - } - else - opt->cap = SANE_CAP_INACTIVE; - } - /* =============== DTC params ================================ */ /* enabled when in dtc mode (manually or by default) */ if(option==OPT_BP_FILTER){ opt->name = "bp-filter"; - opt->title = "BP filter"; - opt->desc = "Improves quality of high resolution ball-point pen text"; + opt->title = SANE_I18N ("BP filter"); + opt->desc = SANE_I18N ("Improves quality of high resolution ball-point pen text"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if(s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3280,15 +3303,14 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_SMOOTHING){ opt->name = "smoothing"; - opt->title = "Smoothing"; - opt->desc = "Enable smoothing for improved OCR"; + opt->title = SANE_I18N ("Smoothing"); + opt->desc = SANE_I18N ("Enable smoothing for improved OCR"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if(s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3298,9 +3320,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_GAMMA_CURVE){ opt->name = "gamma-curve"; - opt->title = "Gamma curve"; - opt->desc = "Gamma curve"; - opt->desc = "Gamma curve, from light to dark, but upper two may not work"; + opt->title = SANE_I18N ("Gamma curve"); + opt->desc = SANE_I18N ("Gamma curve, from light to dark, but upper two may not work"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; @@ -3312,8 +3333,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if(s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3323,8 +3343,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_THRESHOLD_CURVE){ opt->name = "threshold-curve"; - opt->title = "Threshold curve"; - opt->desc = "Threshold curve, from light to dark, but upper two may not be linear"; + opt->title = SANE_I18N ("Threshold curve"); + opt->desc = SANE_I18N ("Threshold curve, from light to dark, but upper two may not be linear"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; @@ -3336,8 +3356,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if(s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3347,15 +3366,14 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_THRESHOLD_WHITE){ opt->name = "threshold-white"; - opt->title = "Threshold white"; - opt->desc = "Set pixels equal to threshold to white instead of black"; + opt->title = SANE_I18N ("Threshold white"); + opt->desc = SANE_I18N ("Set pixels equal to threshold to white instead of black"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if(s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3365,15 +3383,14 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_NOISE_REMOVAL){ opt->name = "noise-removal"; - opt->title = "Noise removal"; - opt->desc = "Noise removal"; + opt->title = SANE_I18N ("Noise removal"); + opt->desc = SANE_I18N ("Noise removal"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if(s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3383,16 +3400,14 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_MATRIX_5){ opt->name = "matrix-5x5"; - opt->title = "Matrix 5x5"; - opt->desc = "Remove 5 pixel square noise"; + opt->title = SANE_I18N ("Matrix 5x5"); + opt->desc = SANE_I18N ("Remove 5 pixel square noise"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if( !s->noise_removal - || s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(!s->noise_removal){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3402,16 +3417,14 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_MATRIX_4){ opt->name = "matrix-4x4"; - opt->title = "Matrix 4x4"; - opt->desc = "Remove 4 pixel square noise"; + opt->title = SANE_I18N ("Matrix 4x4"); + opt->desc = SANE_I18N ("Remove 4 pixel square noise"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if( !s->noise_removal - || s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(!s->noise_removal){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3421,16 +3434,14 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_MATRIX_3){ opt->name = "matrix-3x3"; - opt->title = "Matrix 3x3"; - opt->desc = "Remove 3 pixel square noise"; + opt->title = SANE_I18N ("Matrix 3x3"); + opt->desc = SANE_I18N ("Remove 3 pixel square noise"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if( !s->noise_removal - || s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(!s->noise_removal){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3440,16 +3451,14 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_MATRIX_2){ opt->name = "matrix-2x2"; - opt->title = "Matrix 2x2"; - opt->desc = "Remove 2 pixel square noise"; + opt->title = SANE_I18N ("Matrix 2x2"); + opt->desc = SANE_I18N ("Remove 2 pixel square noise"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if( !s->noise_removal - || s->ipc_mode == WD_ipc_SDTC - || (s->has_sdtc && s->ipc_mode == WD_ipc_DEFAULT)){ + if(!s->noise_removal){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3462,8 +3471,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /* called variance with ipc2, sensitivity with ipc3 */ if(option==OPT_VARIANCE){ opt->name = "variance"; - opt->title = "Variance"; - opt->desc = "Set SDTC variance rate (sensitivity), 0 equals 127"; + opt->title = SANE_I18N ("Variance"); + opt->desc = SANE_I18N ("Set SDTC variance rate (sensitivity), 0 equals 127"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; @@ -3475,7 +3484,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if ( s->has_sdtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - if (s->ipc_mode == WD_ipc_DTC){ + if(get_ipc_mode(s) == WD_ipc_DTC){ opt->cap |= SANE_CAP_INACTIVE; } } @@ -3496,8 +3505,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_AWD){ opt->name = "awd"; - opt->title = "Auto width detection"; - opt->desc = "Scanner detects paper sides. May reduce scanning speed."; + opt->title = SANE_I18N ("Auto width detection"); + opt->desc = SANE_I18N ("Scanner detects paper sides. May reduce scanning speed."); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_NONE; @@ -3514,8 +3523,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ALD){ opt->name = "ald"; - opt->title = "Auto length detection"; - opt->desc = "Scanner detects paper lower edge. May confuse some frontends."; + opt->title = SANE_I18N ("Auto length detection"); + opt->desc = SANE_I18N ("Scanner detects paper lower edge. May confuse some frontends."); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_NONE; @@ -3541,8 +3550,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->compress_list[i]=NULL; opt->name = "compression"; - opt->title = "Compression"; - opt->desc = "Enable compressed data. May crash your front-end program"; + opt->title = SANE_I18N ("Compression"); + opt->desc = SANE_I18N ("Enable compressed data. May crash your front-end program"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->compress_list; @@ -3562,8 +3571,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_COMPRESS_ARG){ opt->name = "compression-arg"; - opt->title = "Compression argument"; - opt->desc = "Level of JPEG compression. 1 is small file, 7 is large file. 0 (default) is same as 4"; + opt->title = SANE_I18N ("Compression argument"); + opt->desc = SANE_I18N ("Level of JPEG compression. 1 is small file, 7 is large file. 0 (default) is same as 4"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -3573,7 +3582,9 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(s->has_comp_JPG1){ s->compress_arg_range.min=0; s->compress_arg_range.max=7; +#ifndef SANE_JPEG_DISABLED opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; +#endif if(s->compress != COMP_JPEG){ opt->cap |= SANE_CAP_INACTIVE; @@ -3591,8 +3602,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->df_action_list[3] = NULL; opt->name = "df-action"; - opt->title = "DF action"; - opt->desc = "Action following double feed error"; + opt->title = SANE_I18N ("DF action"); + opt->desc = SANE_I18N ("Action following double feed error"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->df_action_list; @@ -3608,8 +3619,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_DF_SKEW){ opt->name = "df-skew"; - opt->title = "DF skew"; - opt->desc = "Enable double feed error due to skew"; + opt->title = SANE_I18N ("DF skew"); + opt->desc = SANE_I18N ("Enable double feed error due to skew"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_NONE; @@ -3627,8 +3638,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_DF_THICKNESS){ opt->name = "df-thickness"; - opt->title = "DF thickness"; - opt->desc = "Enable double feed error due to paper thickness"; + opt->title = SANE_I18N ("DF thickness"); + opt->desc = SANE_I18N ("Enable double feed error due to paper thickness"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_NONE; @@ -3646,8 +3657,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_DF_LENGTH){ opt->name = "df-length"; - opt->title = "DF length"; - opt->desc = "Enable double feed error due to paper length"; + opt->title = SANE_I18N ("DF length"); + opt->desc = SANE_I18N ("Enable double feed error due to paper length"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_NONE; @@ -3670,8 +3681,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->df_diff_list[4] = NULL; opt->name = "df-diff"; - opt->title = "DF length difference"; - opt->desc = "Difference in page length to trigger double feed error"; + opt->title = SANE_I18N ("DF length difference"); + opt->desc = SANE_I18N ("Difference in page length to trigger double feed error"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->df_diff_list; @@ -3694,8 +3705,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->df_recovery_list[3] = NULL; opt->name = "df-recovery"; - opt->title = "DF recovery mode"; - opt->desc = "Request scanner to reverse feed on paper jam"; + opt->title = SANE_I18N ("DF recovery mode"); + opt->desc = SANE_I18N ("Request scanner to reverse feed on paper jam"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->df_recovery_list; @@ -3714,8 +3725,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->paper_protect_list[3] = NULL; opt->name = "paper-protect"; - opt->title = "Paper protection"; - opt->desc = "Request scanner to predict jams in the ADF"; + opt->title = SANE_I18N ("Paper protection"); + opt->desc = SANE_I18N ("Request scanner to predict jams in the ADF"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->paper_protect_list; @@ -3734,8 +3745,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->adv_paper_prot_list[3] = NULL; opt->name = "adv-paper-protect"; - opt->title = "Advanced paper protection"; - opt->desc = "Request scanner to predict jams in the ADF using improved sensors"; + opt->title = SANE_I18N ("Advanced paper protection"); + opt->desc = SANE_I18N ("Request scanner to predict jams in the ADF using improved sensors"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->adv_paper_prot_list; @@ -3754,8 +3765,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->staple_detect_list[3] = NULL; opt->name = "staple-detect"; - opt->title = "Staple detection"; - opt->desc = "Request scanner to detect jams in the ADF caused by staples"; + opt->title = SANE_I18N ("Staple detection"); + opt->desc = SANE_I18N ("Request scanner to detect jams in the ADF caused by staples"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->staple_detect_list; @@ -3774,8 +3785,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->bg_color_list[3] = NULL; opt->name = "bgcolor"; - opt->title = "Background color"; - opt->desc = "Set color of background for scans. May conflict with overscan option"; + opt->title = SANE_I18N ("Background color"); + opt->desc = SANE_I18N ("Set color of background for scans. May conflict with overscan option"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->bg_color_list; @@ -3795,8 +3806,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->do_color_list[4] = NULL; opt->name = "dropoutcolor"; - opt->title = "Dropout color"; - opt->desc = "One-pass scanners use only one color during gray or binary scanning, useful for colored paper or ink"; + opt->title = SANE_I18N ("Dropout color"); + opt->desc = SANE_I18N ("One-pass scanners use only one color during gray or binary scanning, useful for colored paper or ink"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->do_color_list; @@ -3819,8 +3830,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->buff_mode_list[3] = NULL; opt->name = "buffermode"; - opt->title = "Buffer mode"; - opt->desc = "Request scanner to read pages quickly from ADF into internal memory"; + opt->title = SANE_I18N ("Buffer mode"); + opt->desc = SANE_I18N ("Request scanner to read pages quickly from ADF into internal memory"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->buff_mode_list; @@ -3839,8 +3850,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->prepick_list[3] = NULL; opt->name = "prepick"; - opt->title = "Prepick"; - opt->desc = "Request scanner to grab next page from ADF"; + opt->title = SANE_I18N ("Prepick"); + opt->desc = SANE_I18N ("Request scanner to grab next page from ADF"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->prepick_list; @@ -3859,8 +3870,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->overscan_list[3] = NULL; opt->name = "overscan"; - opt->title = "Overscan"; - opt->desc = "Collect a few mm of background on top side of scan, before paper enters ADF, and increase maximum scan area beyond paper size, to allow collection on remaining sides. May conflict with bgcolor option"; + opt->title = SANE_I18N ("Overscan"); + opt->desc = SANE_I18N ("Collect a few mm of background on top side of scan, before paper enters ADF, and increase maximum scan area beyond paper size, to allow collection on remaining sides. May conflict with bgcolor option"); opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->overscan_list; @@ -3878,8 +3889,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->sleep_time_range.quant = 1; opt->name = "sleeptimer"; - opt->title = "Sleep timer"; - opt->desc = "Time in minutes until the internal power supply switches to sleep mode"; + opt->title = SANE_I18N ("Sleep timer"); + opt->desc = SANE_I18N ("Time in minutes until the internal power supply switches to sleep mode"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -3897,8 +3908,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->off_time_range.quant = 1; opt->name = "offtimer"; - opt->title = "Off timer"; - opt->desc = "Time in minutes until the internal power supply switches the scanner off. Will be rounded to nearest 15 minutes. Zero means never power off."; + opt->title = SANE_I18N ("Off timer"); + opt->desc = SANE_I18N ("Time in minutes until the internal power supply switches the scanner off. Will be rounded to nearest 15 minutes. Zero means never power off."); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -3916,8 +3927,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->duplex_offset_range.quant = 1; opt->name = "duplexoffset"; - opt->title = "Duplex offset"; - opt->desc = "Adjust front/back offset"; + opt->title = SANE_I18N ("Duplex offset"); + opt->desc = SANE_I18N ("Adjust front/back offset"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -3934,8 +3945,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->green_offset_range.quant = 1; opt->name = "greenoffset"; - opt->title = "Green offset"; - opt->desc = "Adjust green/red offset"; + opt->title = SANE_I18N ("Green offset"); + opt->desc = SANE_I18N ("Adjust green/red offset"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -3952,8 +3963,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) s->blue_offset_range.quant = 1; opt->name = "blueoffset"; - opt->title = "Blue offset"; - opt->desc = "Adjust blue/red offset"; + opt->title = SANE_I18N ("Blue offset"); + opt->desc = SANE_I18N ("Adjust blue/red offset"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -3966,8 +3977,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_LOW_MEM){ opt->name = "lowmemory"; - opt->title = "Low Memory"; - opt->desc = "Limit driver memory usage for use in embedded systems. Causes some duplex transfers to alternate sides on each call to sane_read. Value of option 'side' can be used to determine correct image. This option should only be used with custom front-end software."; + opt->title = SANE_I18N ("Low Memory"); + opt->desc = SANE_I18N ("Limit driver memory usage for use in embedded systems. Causes some duplex transfers to alternate sides on each call to sane_read. Value of option 'side' can be used to determine correct image. This option should only be used with custom front-end software."); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->size = sizeof(SANE_Word); @@ -3982,8 +3993,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_SIDE){ opt->name = "side"; - opt->title = "Duplex side"; - opt->desc = "Tells which side (0=front, 1=back) of a duplex scan the next call to sane_read will return."; + opt->title = SANE_I18N ("Duplex side"); + opt->desc = SANE_I18N ("Tells which side (0=front, 1=back) of a duplex scan the next call to sane_read will return."); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->size = sizeof(SANE_Word); @@ -3994,8 +4005,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /*deskew and crop by hardware*/ if(option==OPT_HWDESKEWCROP){ opt->name = "hwdeskewcrop"; - opt->title = "Hardware deskew and crop"; - opt->desc = "Request scanner to rotate and crop pages digitally."; + opt->title = SANE_I18N ("Hardware deskew and crop"); + opt->desc = SANE_I18N ("Request scanner to rotate and crop pages digitally."); opt->type = SANE_TYPE_BOOL; if (s->has_hybrid_crop_deskew) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; @@ -4006,8 +4017,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /*deskew by software*/ if(option==OPT_SWDESKEW){ opt->name = "swdeskew"; - opt->title = "Software deskew"; - opt->desc = "Request driver to rotate skewed pages digitally."; + opt->title = SANE_I18N ("Software deskew"); + opt->desc = SANE_I18N ("Request driver to rotate skewed pages digitally."); opt->type = SANE_TYPE_BOOL; if (1) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; @@ -4019,8 +4030,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_SWDESPECK){ opt->name = "swdespeck"; - opt->title = "Software despeckle diameter"; - opt->desc = "Maximum diameter of lone dots to remove from scan."; + opt->title = SANE_I18N ("Software despeckle diameter"); + opt->desc = SANE_I18N ("Maximum diameter of lone dots to remove from scan."); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; @@ -4039,8 +4050,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /*crop by software*/ if(option==OPT_SWCROP){ opt->name = "swcrop"; - opt->title = "Software crop"; - opt->desc = "Request driver to remove border from pages digitally."; + opt->title = SANE_I18N ("Software crop"); + opt->desc = SANE_I18N ("Request driver to remove border from pages digitally."); opt->type = SANE_TYPE_BOOL; if (1) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; @@ -4069,8 +4080,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /*halt scanner feeder when cancelling*/ if(option==OPT_HALT_ON_CANCEL){ opt->name = "halt-on-cancel"; - opt->title = "Halt on Cancel"; - opt->desc = "Request driver to halt the paper feed instead of eject during a cancel."; + opt->title = SANE_I18N ("Halt on Cancel"); + opt->desc = SANE_I18N ("Request driver to halt the paper feed instead of eject during a cancel."); opt->type = SANE_TYPE_BOOL; if (s->has_op_halt) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; @@ -4081,8 +4092,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) /* "Endorser" group ------------------------------------------------------ */ if(option==OPT_ENDORSER_GROUP){ opt->name = "endorser-options"; - opt->title = "Endorser Options"; - opt->desc = "Controls for endorser unit"; + opt->title = SANE_I18N ("Endorser Options"); + opt->desc = SANE_I18N ("Controls for endorser unit"); opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; @@ -4093,8 +4104,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER){ opt->name = "endorser"; - opt->title = "Endorser"; - opt->desc = "Enable endorser unit"; + opt->title = SANE_I18N ("Endorser"); + opt->desc = SANE_I18N ("Enable endorser unit"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; opt->size = sizeof(SANE_Word); @@ -4109,8 +4120,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_BITS){ opt->name = "endorser-bits"; - opt->title = "Endorser bits"; - opt->desc = "Determines maximum endorser counter value."; + opt->title = SANE_I18N ("Endorser bits"); + opt->desc = SANE_I18N ("Determines maximum endorser counter value."); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->size = sizeof(SANE_Word); @@ -4135,8 +4146,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_VAL){ opt->name = "endorser-val"; - opt->title = "Endorser value"; - opt->desc = "Initial endorser counter value."; + opt->title = SANE_I18N ("Endorser value"); + opt->desc = SANE_I18N ("Initial endorser counter value."); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->size = sizeof(SANE_Word); @@ -4159,8 +4170,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_STEP){ opt->name = "endorser-step"; - opt->title = "Endorser step"; - opt->desc = "Change endorser counter value by this much for each page."; + opt->title = SANE_I18N ("Endorser step"); + opt->desc = SANE_I18N ("Change endorser counter value by this much for each page."); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->size = sizeof(SANE_Word); @@ -4183,8 +4194,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_Y){ opt->name = "endorser-y"; - opt->title = "Endorser Y"; - opt->desc = "Endorser print offset from top of paper."; + opt->title = SANE_I18N ("Endorser Y"); + opt->desc = SANE_I18N ("Endorser print offset from top of paper."); opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->size = sizeof(SANE_Word); @@ -4209,8 +4220,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_FONT){ opt->name = "endorser-font"; - opt->title = "Endorser font"; - opt->desc = "Endorser printing font."; + opt->title = SANE_I18N ("Endorser font"); + opt->desc = SANE_I18N ("Endorser printing font."); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; @@ -4239,8 +4250,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_DIR){ opt->name = "endorser-dir"; - opt->title = "Endorser direction"; - opt->desc = "Endorser printing direction."; + opt->title = SANE_I18N ("Endorser direction"); + opt->desc = SANE_I18N ("Endorser printing direction."); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; @@ -4264,8 +4275,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_SIDE){ opt->name = "endorser-side"; - opt->title = "Endorser side"; - opt->desc = "Endorser printing side, requires hardware support to change"; + opt->title = SANE_I18N ("Endorser side"); + opt->desc = SANE_I18N ("Endorser printing side, requires hardware support to change"); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; @@ -4290,8 +4301,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ENDORSER_STRING){ opt->name = "endorser-string"; - opt->title = "Endorser string"; - opt->desc = "Endorser alphanumeric print format. %05ud or %08ud at the end will be replaced by counter value."; + opt->title = SANE_I18N ("Endorser string"); + opt->desc = SANE_I18N ("Endorser alphanumeric print format. %05ud or %08ud at the end will be replaced by counter value."); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; opt->size = s->endorser_string_len + 1; @@ -4318,8 +4329,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_TOP){ opt->name = "top-edge"; - opt->title = "Top edge"; - opt->desc = "Paper is pulled partly into adf"; + opt->title = SANE_I18N ("Top edge"); + opt->desc = SANE_I18N ("Paper is pulled partly into adf"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status || s->ghs_in_rs) @@ -4330,8 +4341,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_A3){ opt->name = "a3-paper"; - opt->title = "A3 paper"; - opt->desc = "A3 paper detected"; + opt->title = SANE_I18N ("A3 paper"); + opt->desc = SANE_I18N ("A3 paper detected"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4342,8 +4353,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_B4){ opt->name = "b4-paper"; - opt->title = "B4 paper"; - opt->desc = "B4 paper detected"; + opt->title = SANE_I18N ("B4 paper"); + opt->desc = SANE_I18N ("B4 paper detected"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4354,8 +4365,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_A4){ opt->name = "a4-paper"; - opt->title = "A4 paper"; - opt->desc = "A4 paper detected"; + opt->title = SANE_I18N ("A4 paper"); + opt->desc = SANE_I18N ("A4 paper detected"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4366,8 +4377,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_B5){ opt->name = "b5-paper"; - opt->title = "B5 paper"; - opt->desc = "B5 paper detected"; + opt->title = SANE_I18N ("B5 paper"); + opt->desc = SANE_I18N ("B5 paper detected"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4390,8 +4401,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_OMR){ opt->name = "omr-df"; - opt->title = "OMR or DF"; - opt->desc = "OMR or double feed detected"; + opt->title = SANE_I18N ("OMR or DF"); + opt->desc = SANE_I18N ("OMR or double feed detected"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4414,8 +4425,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_SLEEP){ opt->name = "power-save"; - opt->title = "Power saving"; - opt->desc = "Scanner in power saving mode"; + opt->title = SANE_I18N ("Power saving"); + opt->desc = SANE_I18N ("Scanner in power saving mode"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4438,8 +4449,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_MANUAL_FEED){ opt->name = "manual-feed"; - opt->title = "Manual feed"; - opt->desc = "Manual feed selected"; + opt->title = SANE_I18N ("Manual feed"); + opt->desc = SANE_I18N ("Manual feed selected"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4462,8 +4473,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_FUNCTION){ opt->name = "function"; - opt->title = "Function"; - opt->desc = "Function character on screen"; + opt->title = SANE_I18N ("Function"); + opt->desc = SANE_I18N ("Function character on screen"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status || s->ghs_in_rs) @@ -4474,8 +4485,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_INK_EMPTY){ opt->name = "ink-low"; - opt->title = "Ink low"; - opt->desc = "Imprinter ink running low"; + opt->title = SANE_I18N ("Ink low"); + opt->desc = SANE_I18N ("Imprinter ink running low"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status && (s->has_endorser_f || s->has_endorser_b)) @@ -4486,8 +4497,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_DOUBLE_FEED){ opt->name = "double-feed"; - opt->title = "Double feed"; - opt->desc = "Double feed detected"; + opt->title = SANE_I18N ("Double feed"); + opt->desc = SANE_I18N ("Double feed detected"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status || s->ghs_in_rs) @@ -4498,8 +4509,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_ERROR_CODE){ opt->name = "error-code"; - opt->title = "Error code"; - opt->desc = "Hardware error code"; + opt->title = SANE_I18N ("Error code"); + opt->desc = SANE_I18N ("Hardware error code"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4510,8 +4521,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_SKEW_ANGLE){ opt->name = "skew-angle"; - opt->title = "Skew angle"; - opt->desc = "Requires black background for scanning"; + opt->title = SANE_I18N ("Skew angle"); + opt->desc = SANE_I18N ("Requires black background for scanning"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status) @@ -4522,8 +4533,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_INK_REMAIN){ opt->name = "ink-remain"; - opt->title = "Ink remaining"; - opt->desc = "Imprinter ink level"; + opt->title = SANE_I18N ("Ink remaining"); + opt->desc = SANE_I18N ("Imprinter ink level"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status && (s->has_endorser_f || s->has_endorser_b)) @@ -4534,8 +4545,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_DENSITY_SW){ opt->name = "density"; - opt->title = "Density"; - opt->desc = "Density dial"; + opt->title = SANE_I18N ("Density"); + opt->desc = SANE_I18N ("Density dial"); opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; if (s->ghs_in_rs) @@ -4546,8 +4557,8 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if(option==OPT_DUPLEX_SW){ opt->name = "duplex"; - opt->title = "Duplex switch"; - opt->desc = "Duplex switch"; + opt->title = SANE_I18N ("Duplex switch"); + opt->desc = SANE_I18N ("Duplex switch"); opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->ghs_in_rs) @@ -4749,18 +4760,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, } return SANE_STATUS_GOOD; - case OPT_IPC_MODE: - if(s->ipc_mode == WD_ipc_DEFAULT){ - strcpy (val, STRING_DEFAULT); - } - else if(s->ipc_mode == WD_ipc_DTC){ - strcpy (val, STRING_DTC); - } - else if(s->ipc_mode == WD_ipc_SDTC){ - strcpy (val, STRING_SDTC); - } - return SANE_STATUS_GOOD; - + /* DTC params*/ case OPT_BP_FILTER: *val_p = s->bp_filter; return SANE_STATUS_GOOD; @@ -4801,6 +4801,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, *val_p = s->matrix_2; return SANE_STATUS_GOOD; + /* SDTC params*/ case OPT_VARIANCE: *val_p = s->variance; return SANE_STATUS_GOOD; @@ -5357,6 +5358,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (s->page_width == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; + /* if full width image, and paper size is changed, + change the image size to match new paper */ + if (s->tl_x == 0 && s->br_x == s->page_width){ + DBG (20, "sane_control_option: br_x tracking page_width\n"); + s->br_x = FIXED_MM_TO_SCANNER_UNIT(val_c); + *info |= SANE_INFO_RELOAD_PARAMS; + } + s->page_width = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; @@ -5365,6 +5374,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (s->page_height == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; + /* if full height image, and paper size is changed, + change the image size to match new paper */ + if (s->tl_y == 0 && s->br_y == s->page_height){ + DBG (20, "sane_control_option: br_y tracking page_height\n"); + s->br_y = FIXED_MM_TO_SCANNER_UNIT(val_c); + *info |= SANE_INFO_RELOAD_PARAMS; + } + s->page_height = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; @@ -5429,48 +5446,35 @@ sane_control_option (SANE_Handle handle, SANE_Int option, s->wl_follow = WD_wl_follow_OFF; return SANE_STATUS_GOOD; - case OPT_IPC_MODE: - if (!strcmp (val, STRING_DEFAULT)) { - tmp = WD_ipc_DEFAULT; - } - else if (!strcmp (val, STRING_DTC)) { - tmp = WD_ipc_DTC; - } - else { - tmp = WD_ipc_SDTC; - } - - if (tmp != s->ipc_mode) - *info |= SANE_INFO_RELOAD_OPTIONS; - - s->ipc_mode = tmp; - return SANE_STATUS_GOOD; - + /* DTC params*/ case OPT_BP_FILTER: s->bp_filter = val_c; + *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_SMOOTHING: s->smoothing = val_c; + *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_GAMMA_CURVE: s->gamma_curve = val_c; + *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_THRESHOLD_CURVE: s->threshold_curve = val_c; + *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_THRESHOLD_WHITE: s->threshold_white = val_c; + *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_NOISE_REMOVAL: - if (val_c != s->noise_removal) - *info |= SANE_INFO_RELOAD_OPTIONS; - s->noise_removal = val_c; + *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_MATRIX_5: @@ -5489,8 +5493,10 @@ sane_control_option (SANE_Handle handle, SANE_Int option, s->matrix_2 = val_c; return SANE_STATUS_GOOD; + /* SDTC params*/ case OPT_VARIANCE: s->variance = val_c; + *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; /* Advanced Group */ @@ -6681,7 +6687,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) return ret; } -/* set s_param and u_param data based on user settings +/* set s_params and u_params data based on user settings * and scanner capabilities. */ SANE_Status update_params (struct fujitsu * s) @@ -6926,8 +6932,9 @@ sane_start (SANE_Handle handle) if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot send_endorser %d\n", ret); - /* send lut if scanner has no hardware brightness/contrast */ - if (!s->late_lut && (!s->brightness_steps || !s->contrast_steps)){ + /* send lut if scanner has no hardware brightness/contrast, + * or we are going to ask it to use a downloaded gamma table */ + if (!s->late_lut && (!s->brightness_steps || !s->contrast_steps || s->window_gamma & 0x80)){ ret = send_lut(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot early send_lut %d\n", ret); @@ -6940,8 +6947,9 @@ sane_start (SANE_Handle handle) goto errors; } - /* send lut if scanner has no hardware brightness/contrast */ - if (s->late_lut && (!s->brightness_steps || !s->contrast_steps)){ + /* send lut if scanner has no hardware brightness/contrast, + * or we are going to ask it to use a downloaded gamma table */ + if (s->late_lut && (!s->brightness_steps || !s->contrast_steps || s->window_gamma & 0x80)){ ret = send_lut(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot late send_lut %d\n", ret); @@ -7573,15 +7581,15 @@ set_window (struct fujitsu *s) set_WD_separation(desc1,s->separation); set_WD_mirroring(desc1,s->mirroring); - if (s->has_sdtc && s->ipc_mode != WD_ipc_DTC) + if (get_ipc_mode(s) == WD_ipc_SDTC) set_WD_variance(desc1,s->variance); - if ((s->has_dtc && !s->has_sdtc) || s->ipc_mode == WD_ipc_DTC){ - set_WD_filtering(desc1,!s->bp_filter); - set_WD_smoothing(desc1,!s->smoothing); + else if (get_ipc_mode(s) == WD_ipc_DTC){ + set_WD_filtering(desc1,s->bp_filter); + set_WD_smoothing(desc1,s->smoothing); set_WD_gamma_curve(desc1,s->gamma_curve); set_WD_threshold_curve(desc1,s->threshold_curve); - set_WD_noise_removal(desc1,!s->noise_removal); + set_WD_noise_removal(desc1,s->noise_removal); if(s->noise_removal){ set_WD_matrix5x5(desc1,s->matrix_5); set_WD_matrix4x4(desc1,s->matrix_4); @@ -7593,7 +7601,7 @@ set_window (struct fujitsu *s) set_WD_wl_follow(desc1,s->wl_follow); set_WD_subwindow_list(desc1,0); - set_WD_ipc_mode(desc1,s->ipc_mode); + set_WD_ipc_mode(desc1,get_ipc_mode(s)); } else{ @@ -7691,8 +7699,8 @@ get_pixelsize(struct fujitsu *s, int actual) /* when we are called post-scan, the scanner may give * more accurate data in other fields */ if(actual && !s->has_short_pixelsize && get_PSIZE_paper_w(in)){ + DBG(5,"get_pixelsize: Actual width %d -> %d\n", s->s_params.pixels_per_line, get_PSIZE_paper_w(in)); s->s_params.pixels_per_line = get_PSIZE_paper_w(in); - DBG(5,"get_pixelsize: Actual width\n"); } else{ s->s_params.pixels_per_line = get_PSIZE_num_x(in); @@ -7707,8 +7715,8 @@ get_pixelsize(struct fujitsu *s, int actual) /* when we are called post-scan, the scanner may give * more accurate data in other fields */ else if(actual && !s->has_short_pixelsize && get_PSIZE_paper_l(in)){ + DBG(5,"get_pixelsize: Actual length %d -> %d\n", s->s_params.lines, get_PSIZE_paper_l(in)); s->s_params.lines = get_PSIZE_paper_l(in); - DBG(5,"get_pixelsize: Actual length\n"); } else{ s->s_params.lines = get_PSIZE_num_y(in); @@ -9867,6 +9875,43 @@ get_page_height(struct fujitsu *s) return height; } +/* scanners have two different possible IPC + * modes, which enable a different series of + * subordinate options. Rather than provide + * the user with an option to pick the IPC + * mode, we show them the subordinate ones, + * and pick the right mode to match. + */ +static int +get_ipc_mode(struct fujitsu *s) +{ + if ( s->bp_filter + || s->smoothing + || s->gamma_curve + || s->threshold_curve + || s->threshold_white + || s->noise_removal + || s->matrix_5 + || s->matrix_4 + || s->matrix_3 + || s->matrix_2 + ) + return WD_ipc_DTC; + + if(s->variance) + return WD_ipc_SDTC; + + /* special case: 0 threshold should activate IPC */ + if(!s->threshold){ + if(s->has_sdtc) + return WD_ipc_SDTC; + if(s->has_dtc) + return WD_ipc_DTC; + } + + return WD_ipc_DEFAULT; +} + /* s->max_y gives the maximum height of paper which can be scanned * this actually varies by resolution, so a helper to change it */ static int diff --git a/backend/fujitsu.conf.in b/backend/fujitsu.conf.in index b3895ea..5fa0003 100644 --- a/backend/fujitsu.conf.in +++ b/backend/fujitsu.conf.in @@ -121,7 +121,13 @@ usb 0x04c5 0x119e #S1500 & S1500M usb 0x04c5 0x11a2 -#fi-6140Z +#fi-6125 +usb 0x04c5 0x11ee + +#fi-6225 +usb 0x04c5 0x11ef + +#fi-6140Z/fi-6160ZLA usb 0x04c5 0x11f1 #fi-6240Z @@ -157,6 +163,108 @@ usb 0x04c5 0x132e #fi-7260 usb 0x04c5 0x132f +#ScanSnap iX500EE +usb 0x04c5 0x13f3 + #ScanSnap iX100 usb 0x04c5 0x13f4 +#ScanPartner SP25 +usb 0x04c5 0x1409 + +#ScanPartner SP30 +usb 0x04c5 0x140a + +#ScanPartner SP30F +usb 0x04c5 0x140c + +#fi-6140ZLA +usb 0x04c5 0x145f + +#fi-6240ZLA +usb 0x04c5 0x1460 + +#fi-6130ZLA +usb 0x04c5 0x1461 + +#fi-6230ZLA +usb 0x04c5 0x1462 + +#fi-6125ZLA +usb 0x04c5 0x1463 + +#fi-6225ZLA +usb 0x04c5 0x1464 + +#fi-6135ZLA +usb 0x04c5 0x146b + +#fi-6235ZLA +usb 0x04c5 0x146c + +#fi-6120ZLA +usb 0x04c5 0x146d + +#fi-6220ZLA +usb 0x04c5 0x146e + +#N7100 +usb 0x04c5 0x146f + +#fi-6400 +usb 0x04c5 0x14ac + +#fi-7480 +usb 0x04c5 0x14b8 + +#fi-6420 +usb 0x04c5 0x14bd + +#fi-7460 +usb 0x04c5 0x14be + +#fi-7140 +usb 0x04c5 0x14df + +#fi-7240 +usb 0x04c5 0x14e0 + +#fi-7135 +usb 0x04c5 0x14e1 + +#fi-7235 +usb 0x04c5 0x14e2 + +#fi-7130 +usb 0x04c5 0x14e3 + +#fi-7230 +usb 0x04c5 0x14e4 + +#fi-7125 +usb 0x04c5 0x14e5 + +#fi-7225 +usb 0x04c5 0x14e6 + +#fi-7120 +usb 0x04c5 0x14e7 + +#fi-7220 +usb 0x04c5 0x14e8 + +#fi-400F +usb 0x04c5 0x151e + +#fi-7030 +usb 0x04c5 0x151f + +#fi-7700 +usb 0x04c5 0x1520 + +#fi-7600 +usb 0x04c5 0x1521 + +#fi-7700S +usb 0x04c5 0x1522 + diff --git a/backend/fujitsu.h b/backend/fujitsu.h index 6ce1a56..916f069 100644 --- a/backend/fujitsu.h +++ b/backend/fujitsu.h @@ -43,7 +43,6 @@ enum fujitsu_Option OPT_SEPARATION, OPT_MIRRORING, OPT_WL_FOLLOW, - OPT_IPC_MODE, /*IPC/DTC*/ OPT_BP_FILTER, @@ -386,7 +385,6 @@ struct fujitsu SANE_Range ht_pattern_range; SANE_Range emphasis_range; SANE_String_Const wl_follow_list[4]; - SANE_String_Const ipc_mode_list[4]; SANE_Range gamma_curve_range; SANE_Range threshold_curve_range; SANE_Range variance_range; @@ -456,7 +454,6 @@ struct fujitsu int separation; int mirroring; int wl_follow; - int ipc_mode; /* ipc_mode=DTC */ int bp_filter; @@ -534,12 +531,6 @@ struct fujitsu SANE_Parameters u_params; SANE_Parameters s_params; - /* also keep a backup copy, in case the software enhancement code overwrites*/ - /* - SANE_Parameters u_params_bk; - SANE_Parameters s_params_bk; - */ - /* --------------------------------------------------------------------- */ /* values which are set by scanning functions to keep track of pages, etc */ int started; @@ -821,6 +812,7 @@ static int must_downsample (struct fujitsu *s); static int must_fully_buffer (struct fujitsu *s); static int get_page_width (struct fujitsu *s); static int get_page_height (struct fujitsu *s); +static int get_ipc_mode (struct fujitsu *s); static int set_max_y (struct fujitsu *s); static SANE_Status send_lut (struct fujitsu *s); diff --git a/backend/genesys.c b/backend/genesys.c index 984cead..db0a2b2 100644 --- a/backend/genesys.c +++ b/backend/genesys.c @@ -2,7 +2,7 @@ Copyright (C) 2003, 2004 Henning Meier-Geinitz Copyright (C) 2004, 2005 Gerhard Jaeger - Copyright (C) 2004-2015 Stéphane Voltz + Copyright (C) 2004-2016 Stéphane Voltz Copyright (C) 2005-2009 Pierre Willenbrock Copyright (C) 2006 Laurent Charpentier Copyright (C) 2007 Luke @@ -58,7 +58,7 @@ * SANE backend for Genesys Logic GL646/GL841/GL842/GL843/GL846/GL847/GL124 based scanners */ -#define BUILD 2508 +#define BUILD 2511 #define BACKEND_NAME genesys #include "genesys.h" @@ -387,7 +387,7 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev, DBG (DBG_proc, "%s: step_type = %d, " - "exposure_time = %d, yres = %g, power_mode = %d\n", __FUNCTION__, step_type, + "exposure_time = %d, yres = %g, power_mode = %d\n", __func__, step_type, exposure_time, yres, power_mode); /* final speed */ @@ -792,7 +792,7 @@ sanei_genesys_exposure_time2 (Genesys_Device * dev, float ydpi, exposure = exposure_by_led; DBG (DBG_info, "%s: ydpi=%d, step=%d, endpixel=%d led=%d, power=%d => exposure=%d\n", - __FUNCTION__, (int)ydpi, step_type, endpixel, exposure_by_led, power_mode, exposure); + __func__, (int)ydpi, step_type, endpixel, exposure_by_led, power_mode, exposure); return exposure; } @@ -928,7 +928,7 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, int start_address; SANE_Status status; - DBG (DBG_proc, "%s: (size = %d)\n", __FUNCTION__, size); + DBG (DBG_proc, "%s: (size = %d)\n", __func__, size); /* ASIC higher than gl843 doesn't have register 2A/2B, so we route to * a per ASIC shading data loading function if available. @@ -978,7 +978,7 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, status = sanei_genesys_set_buffer_address (dev, start_address); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set buffer address: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus (status)); return status; } @@ -986,7 +986,7 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading table: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to send shading table: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1046,7 +1046,7 @@ sanei_genesys_init_shading_data (Genesys_Device * dev, int pixels_per_line) free (shading_data); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading data: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to send shading data: %s\n", __func__, sane_strstatus (status)); } @@ -1489,7 +1489,7 @@ genesys_coarse_calibration (Genesys_Device * dev) status = dev->model->cmd_set->set_fe (dev, AFE_INIT); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set frontend: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus (status)); free(all_data); free(calibration_data); @@ -2069,9 +2069,12 @@ genesys_white_shading_calibration (Genesys_Device * dev) /* turn on motor and lamp power */ dev->model->cmd_set->set_lamp_power (dev, dev->calib_reg, SANE_TRUE); dev->model->cmd_set->set_motor_power (dev->calib_reg, motor); - if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK) + + /* if needed, go back before doin next scan, by using rewind, registers and + * slopes table are kept intact from previous scan */ + if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK && dev->model->cmd_set->rewind) { - status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE); + status = dev->model->cmd_set->rewind (dev); } status = @@ -2180,7 +2183,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) SANE_Bool motor; - DBG (DBG_proc, "%s: (lines = %d)\n", __FUNCTION__, (unsigned int)dev->calib_lines); + DBG (DBG_proc, "%s: (lines = %d)\n", __func__, (unsigned int)dev->calib_lines); pixels_per_line = dev->calib_pixels; channels = dev->calib_channels; @@ -2193,7 +2196,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) dev->white_average_data = malloc (dev->average_size); if (!dev->white_average_data) { - DBG (DBG_error, "%s: failed to allocate white average memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate white average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2203,7 +2206,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) dev->dark_average_data = malloc (channels * 2 * pixels_per_line); if (!dev->dark_average_data) { - DBG (DBG_error, "%s: failed to allocate dark average memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate dark average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2212,7 +2215,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) calibration_data = malloc (size); if (!calibration_data) { - DBG (DBG_error, "%s: failed to allocate calibration memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate calibration memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2233,7 +2236,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2243,7 +2246,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to begin scan: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2252,7 +2255,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to read data: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2261,7 +2264,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: Failed to end scan: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: Failed to end scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2434,7 +2437,7 @@ compute_averaged_planar (Genesys_Device * dev, unsigned int x, i, j, br, dk, res, avgpixels, basepixels, val; unsigned int fill,factor; - DBG (DBG_info, "%s: pixels=%d, offset=%d\n", __FUNCTION__, pixels_per_line, o); + DBG (DBG_info, "%s: pixels=%d, offset=%d\n", __func__, pixels_per_line, o); /* initialize result */ memset (shading_data, 0xff, words_per_color * 3 * 2); @@ -2504,9 +2507,9 @@ compute_averaged_planar (Genesys_Device * dev, fill=1; } - DBG (DBG_info, "%s: averaging over %d pixels\n", __FUNCTION__, avgpixels); - DBG (DBG_info, "%s: packing factor is %d\n", __FUNCTION__, factor); - DBG (DBG_info, "%s: fill length is %d\n", __FUNCTION__, fill); + DBG (DBG_info, "%s: averaging over %d pixels\n", __func__, avgpixels); + DBG (DBG_info, "%s: packing factor is %d\n", __func__, factor); + DBG (DBG_info, "%s: fill length is %d\n", __func__, fill); for (x = 0; x <= pixels_per_line - avgpixels; x += avgpixels) { @@ -2903,7 +2906,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) shading_data = malloc (length); if (!shading_data) { - DBG (DBG_error, "%s: failed to allocate memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } memset (shading_data, 0, length); @@ -3071,7 +3074,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) shading_data = malloc (length); if (!shading_data) { - DBG (DBG_error, "%s: failed to allocate memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } memset (shading_data, 0, length); @@ -3121,7 +3124,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) 256); /* patch_size: contigous extent */ break; default: - DBG (DBG_error, "%s: sensor %d not supported\n", __FUNCTION__, dev->model->ccd_type); + DBG (DBG_error, "%s: sensor %d not supported\n", __func__, dev->model->ccd_type); return SANE_STATUS_UNSUPPORTED; break; } @@ -3131,7 +3134,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) free (shading_data); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading data: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to send shading data: %s\n", __func__, sane_strstatus (status)); } @@ -3689,7 +3692,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { dev->model->cmd_set->eject_document (dev); - DBG (DBG_error, "%s: failed eject target: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed eject target: %s\n", __func__, sane_strstatus (status)); return status; } @@ -3821,7 +3824,7 @@ genesys_warmup_lamp (Genesys_Device * dev) /* check if the current chipset implements warmup */ if(dev->model->cmd_set->init_regs_for_warmup==NULL) { - DBG (DBG_error, "%s: init_regs_for_warmup not implemented\n", __FUNCTION__); + DBG (DBG_error, "%s: init_regs_for_warmup not implemented\n", __func__); return status; } @@ -4346,7 +4349,7 @@ genesys_fill_line_interp_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -4383,7 +4386,7 @@ genesys_fill_line_interp_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -4417,7 +4420,7 @@ genesys_fill_segmented_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, s if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -4508,7 +4511,7 @@ genesys_fill_segmented_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, s if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -5496,7 +5499,7 @@ GENESYS_STATIC char *calibration_filename(Genesys_Device *currdev) snprintf (tmpstr, PATH_MAX, "%s%c.sane%c%s", ptr, PATH_SEP, PATH_SEP, filename); } - DBG (DBG_info, "%s: calibration filename >%s<\n", __FUNCTION__, tmpstr); + DBG (DBG_info, "%s: calibration filename >%s<\n", __func__, tmpstr); return tmpstr; } @@ -5893,7 +5896,7 @@ init_options (Genesys_Scanner * s) DISABLE (OPT_COLOR_FILTER); } - /* calibration stor file name */ + /* calibration store file name */ s->opt[OPT_CALIBRATION_FILE].name = "calibration-file"; s->opt[OPT_CALIBRATION_FILE].title = SANE_I18N ("Calibration file"); s->opt[OPT_CALIBRATION_FILE].desc = SANE_I18N ("Specify the calibration file to use"); @@ -6330,7 +6333,7 @@ probe_genesys_devices (void) free (new_dev); } - DBG(DBG_info, "%s: %d devices currently attached\n", __FUNCTION__, num_devices); + DBG(DBG_info, "%s: %d devices currently attached\n", __func__, num_devices); DBGCOMPLETED; @@ -6545,7 +6548,7 @@ genesys_buffer_image(Genesys_Scanner *s) lines = (SANE_UNFIX (dev->model->y_size) * dev->settings.yres) / MM_PER_INCH; } - DBG (DBG_info, "%s: buffering %d lines of %d bytes\n", __FUNCTION__, lines, + DBG (DBG_info, "%s: buffering %d lines of %d bytes\n", __func__, lines, s->params.bytes_per_line); /* maximum bytes to read */ @@ -6568,7 +6571,7 @@ genesys_buffer_image(Genesys_Scanner *s) { DBG (DBG_error, "%s: digital processing requires too much memory.\nConsider disabling it\n", - __FUNCTION__); + __func__); return SANE_STATUS_NO_MEM; } @@ -6585,7 +6588,7 @@ genesys_buffer_image(Genesys_Scanner *s) if (status != SANE_STATUS_EOF && status != SANE_STATUS_GOOD) { free (s->dev->img_buffer); - DBG (DBG_error, "%s: %s buffering failed\n", __FUNCTION__, + DBG (DBG_error, "%s: %s buffering failed\n", __func__, sane_strstatus (status)); return status; } @@ -6600,7 +6603,7 @@ genesys_buffer_image(Genesys_Scanner *s) { DBG (DBG_error0, "%s: digital processing requires too much memory.\nConsider disabling it\n", - __FUNCTION__); + __func__); return SANE_STATUS_NO_MEM; } } @@ -6627,7 +6630,7 @@ genesys_buffer_image(Genesys_Scanner *s) { DBG (DBG_error0, "%s: digital processing requires too much memory.\nConsider disabling it\n", - __FUNCTION__); + __func__); return SANE_STATUS_NO_MEM; } genesys_gray_lineart (dev, @@ -6669,10 +6672,10 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) DBG_INIT (); DBG (DBG_init, "SANE Genesys backend version %d.%d build %d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB DBG (DBG_init, "SANE Genesys backend built with libusb-1.0\n"); #endif -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY DBG (DBG_init, "SANE Genesys backend built with libusb\n"); #endif @@ -6942,8 +6945,8 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) tmpstr=calibration_filename(s->dev); s->val[OPT_CALIBRATION_FILE].s = strdup (tmpstr); s->dev->calib_file = strdup (tmpstr); - DBG (DBG_info, "%s: Calibration filename set to:\n", __FUNCTION__); - DBG (DBG_info, "%s: >%s<\n", __FUNCTION__, s->dev->calib_file); + DBG (DBG_info, "%s: Calibration filename set to:\n", __func__); + DBG (DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); free(tmpstr); /* now open file, fetch calibration records */ @@ -7033,7 +7036,9 @@ sane_close (SANE_Handle handle) FREE_IFNOT_NULL (s->dev->sensor.gamma_table[1]); FREE_IFNOT_NULL (s->dev->sensor.gamma_table[2]); - /* for an handful of bytes .. */ + s->dev->already_initialized = SANE_FALSE; + + /* for an handful of bytes .. */ free ((void *)(size_t)s->opt[OPT_RESOLUTION].constraint.word_list); free (s->val[OPT_SOURCE].s); free (s->val[OPT_MODE].s); @@ -7125,6 +7130,7 @@ get_option_value (Genesys_Scanner * s, int option, void *val) case OPT_DESPECK: case OPT_CONTRAST: case OPT_BRIGHTNESS: + case OPT_EXPIRATION_TIME: *(SANE_Word *) val = s->val[option].w; break; case OPT_CUSTOM_GAMMA: @@ -7245,8 +7251,8 @@ static SANE_Status set_calibration_value (Genesys_Scanner * s, int option, void if (tmp) free (tmp); dev->calib_file = strdup (val); - DBG (DBG_info, "%s: Calibration filename set to:\n", __FUNCTION__); - DBG (DBG_info, "%s: >%s<\n", __FUNCTION__, s->dev->calib_file); + DBG (DBG_info, "%s: Calibration filename set to:\n", __func__); + DBG (DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -7536,7 +7542,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val, { DBG (DBG_error, "%s: failed to disable power saving mode: %s\n", - __FUNCTION__, sane_strstatus (status)); + __func__, sane_strstatus (status)); } else status = genesys_scanner_calibration (s->dev); diff --git a/backend/genesys.conf.in b/backend/genesys.conf.in index 7899455..5273d51 100644 --- a/backend/genesys.conf.in +++ b/backend/genesys.conf.in @@ -2,7 +2,7 @@ # # scanners that are not yet supported -# uncomment them only for developpment purpose +# uncomment them only for development purpose # # UMAX Astra 4500 and Avision iVina 1600 diff --git a/backend/genesys_conv.c b/backend/genesys_conv.c index 0346ad6..61f466e 100644 --- a/backend/genesys_conv.c +++ b/backend/genesys_conv.c @@ -1,7 +1,7 @@ /* sane - Scanner Access Now Easy. Copyright (C) 2005, 2006 Pierre Willenbrock - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2013 Stéphane Voltz This file is part of the SANE package. @@ -295,7 +295,7 @@ genesys_shrink_lines_1 ( else { /* TODO: since depth is 1, we must interpolate bit within bytes */ - DBG (DBG_warn, "%s: inaccurate bit expansion!\n", __FUNCTION__); + DBG (DBG_warn, "%s: inaccurate bit expansion!\n", __func__); cnt = dst_pixels / 2; dst_x = 0; for (src_x = 0; src_x < src_pixels; src_x++) @@ -332,7 +332,7 @@ genesys_crop(Genesys_Scanner *s) int left = 0; int right = 0; - DBG (DBG_proc, "%s: start\n", __FUNCTION__); + DBG (DBG_proc, "%s: start\n", __func__); /* first find edges if any */ status = sanei_magic_findEdges (&s->params, @@ -345,10 +345,10 @@ genesys_crop(Genesys_Scanner *s) &right); if (status != SANE_STATUS_GOOD) { - DBG (DBG_info, "%s: bad or no edges, bailing\n", __FUNCTION__); + DBG (DBG_info, "%s: bad or no edges, bailing\n", __func__); goto cleanup; } - DBG (DBG_io, "%s: t:%d b:%d l:%d r:%d\n", __FUNCTION__, top, bottom, left, + DBG (DBG_io, "%s: t:%d b:%d l:%d r:%d\n", __func__, top, bottom, left, right); /* now crop the image */ @@ -356,7 +356,7 @@ genesys_crop(Genesys_Scanner *s) sanei_magic_crop (&(s->params), dev->img_buffer, top, bottom, left, right); if (status) { - DBG (DBG_warn, "%s: failed to crop\n", __FUNCTION__); + DBG (DBG_warn, "%s: failed to crop\n", __func__); goto cleanup; } @@ -364,7 +364,7 @@ genesys_crop(Genesys_Scanner *s) dev->total_bytes_to_read = s->params.bytes_per_line * s->params.lines; cleanup: - DBG (DBG_proc, "%s: completed\n", __FUNCTION__); + DBG (DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -382,7 +382,7 @@ genesys_deskew(Genesys_Scanner *s) int x = 0, y = 0, bg; double slope = 0; - DBG (DBG_proc, "%s: start\n", __FUNCTION__); + DBG (DBG_proc, "%s: start\n", __func__); bg=0; if(s->params.format==SANE_FRAME_GRAY && s->params.depth == 1) @@ -398,10 +398,10 @@ genesys_deskew(Genesys_Scanner *s) &slope); if (status!=SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: bad findSkew, bailing\n", __FUNCTION__); + DBG (DBG_error, "%s: bad findSkew, bailing\n", __func__); return SANE_STATUS_GOOD; } - DBG(DBG_info, "%s: slope=%f => %f\n",__FUNCTION__,slope, (slope/M_PI_2)*90); + DBG(DBG_info, "%s: slope=%f => %f\n",__func__,slope, (slope/M_PI_2)*90); /* rotate image slope is in [-PI/2,PI/2] * positive values rotate trigonometric direction wise */ status = sanei_magic_rotate (&s->params, @@ -412,10 +412,10 @@ genesys_deskew(Genesys_Scanner *s) bg); if (status!=SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: rotate error: %s", __FUNCTION__, sane_strstatus(status)); + DBG (DBG_error, "%s: rotate error: %s", __func__, sane_strstatus(status)); } - DBG (DBG_proc, "%s: completed\n", __FUNCTION__); + DBG (DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -430,7 +430,7 @@ genesys_despeck(Genesys_Scanner *s) s->dev->img_buffer, s->val[OPT_DESPECK].w)!=SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: bad despeck, bailing\n",__FUNCTION__); + DBG (DBG_error, "%s: bad despeck, bailing\n",__func__); } return SANE_STATUS_GOOD; @@ -454,7 +454,7 @@ genesys_derotate (Genesys_Scanner * s) if (status) { - DBG (DBG_warn, "%s: failed : %d\n", __FUNCTION__, status); + DBG (DBG_warn, "%s: failed : %d\n", __func__, status); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -463,7 +463,7 @@ genesys_derotate (Genesys_Scanner * s) status = sanei_magic_turn (&s->params, s->dev->img_buffer, angle); if (status) { - DBG (DBG_warn, "%s: failed : %d\n", __FUNCTION__, status); + DBG (DBG_warn, "%s: failed : %d\n", __func__, status); DBGCOMPLETED; return SANE_STATUS_GOOD; } diff --git a/backend/genesys_devices.c b/backend/genesys_devices.c index 775ffb6..11f2579 100644 --- a/backend/genesys_devices.c +++ b/backend/genesys_devices.c @@ -3,12 +3,12 @@ Copyright (C) 2003 Oliver Rauch Copyright (C) 2003-2005 Henning Meier-Geinitz Copyright (C) 2004, 2005 Gerhard Jaeger - Copyright (C) 2004-2013 Stéphane Voltz + Copyright (C) 2004-2013 Stéphane Voltz Copyright (C) 2005-2009 Pierre Willenbrock Copyright (C) 2007 Luke Copyright (C) 2010 Jack McGill Copyright (C) 2010 Andrey Loginov , - xerox travelscan device entry + xerox travelscan device entry Copyright (C) 2010 Chris Berry and Michael Rickmann for Plustek Opticbook 3600 support @@ -64,28 +64,28 @@ static Genesys_Frontend Wolfson[] = { , {0x02, 0x02, 0x02} , {0x00, 0x00, 0x00} } - , /* 0: UMAX */ + , /* 0: UMAX */ {DAC_WOLFSON_ST12, {0x00, 0x03, 0x05, 0x03} , {0x00, 0x00, 0x00} , {0xc8, 0xc8, 0xc8} , {0x04, 0x04, 0x04} , {0x00, 0x00, 0x00} } - , /* 1: ST12 */ + , /* 1: ST12 */ {DAC_WOLFSON_ST24,{0x00, 0x03, 0x05, 0x21} , {0x00, 0x00, 0x00} , {0xc8, 0xc8, 0xc8} , {0x06, 0x06, 0x06} , {0x00, 0x00, 0x00} } - , /* 2: ST24 */ + , /* 2: ST24 */ {DAC_WOLFSON_5345,{0x00, 0x03, 0x05, 0x12} , {0x00, 0x00, 0x00} , {0xb8, 0xb8, 0xb8} , {0x04, 0x04, 0x04} , {0x00, 0x00, 0x00} } - , /* 3: MD6228/MD6471 */ + , /* 3: MD6228/MD6471 */ {DAC_WOLFSON_HP2400, /* reg0 reg1 reg2 reg3 */ {0x00, 0x03, 0x05, 0x02} /* reg3=0x02 for 50-600 dpi, 0x32 (0x12 also works well) at 1200 */ @@ -94,7 +94,7 @@ static Genesys_Frontend Wolfson[] = { , {0x06, 0x09, 0x08} , {0x00, 0x00, 0x00} } - , /* 4: HP2400c */ + , /* 4: HP2400c */ {DAC_WOLFSON_HP2300, {0x00, 0x03, 0x04, 0x02} , {0x00, 0x00, 0x00} @@ -102,16 +102,16 @@ static Genesys_Frontend Wolfson[] = { , {0x04, 0x04, 0x04} , {0x00, 0x00, 0x00} } - , /* 5: HP2300c */ + , /* 5: HP2300c */ {DAC_CANONLIDE35,{0x00, 0x3d, 0x08, 0x00} , {0x00, 0x00, 0x00} , {0xe1, 0xe1, 0xe1} , {0x93, 0x93, 0x93} , {0x00, 0x19, 0x06} } - , /* 6: CANONLIDE35 */ + , /* 6: CANONLIDE35 */ {DAC_AD_XP200, - {0x58, 0x80, 0x00, 0x00} /* reg1=0x80 ? */ + {0x58, 0x80, 0x00, 0x00} /* reg1=0x80 ? */ , {0x00, 0x00, 0x00} , {0x09, 0x09, 0x09} , {0x09, 0x09, 0x09} @@ -124,7 +124,7 @@ static Genesys_Frontend Wolfson[] = { , {0x93, 0x93, 0x93} , {0x07, 0x00, 0x00} } - , /* 8: HP3670 */ + , /* 8: HP3670 */ {DAC_WOLFSON_HP3670, /* reg0 reg1 reg2 reg3 */ {0x00, 0x03, 0x05, 0x32} /* reg3=0x32 for 100-300 dpi, 0x12 at 1200 */ @@ -156,7 +156,7 @@ static Genesys_Frontend Wolfson[] = { , {0x2f, 0x04, 0x00} , {0x00, 0x00, 0x00} } - , /* KV-SS080 */ + , /* KV-SS080 */ {DAC_KVSS080, {0x00, 0x23, 0x24, 0x0f} , {0x00, 0x00, 0x00} @@ -168,7 +168,7 @@ static Genesys_Frontend Wolfson[] = { {DAC_G4050, {0x00, 0x23, 0x24, 0x1f} , {0x00, 0x00, 0x00} - , {0x45, 0x45, 0x45} /* 0x20, 0x21, 0x22 */ + , {0x45, 0x45, 0x45} /* 0x20, 0x21, 0x22 */ , {0x4b, 0x4b, 0x4b} /* 0x28, 0x29, 0x2a */ , {0x00,0x00,0x00} } @@ -181,6 +181,22 @@ static Genesys_Frontend Wolfson[] = { , {0x00, 0x00, 0x00} } , + /** @brief GL124 special case + * for GL124 based scanners, this struct is "abused" + * in fact the fields are map like below to AFE registers + * (from Texas Instrument or alike ?) + */ + {DAC_CANONLIDE120, + {0x80, + /* 0001 0002 0003 */ + 0xa3, 0x2b, 0x4c} + /* 0005 0006 0007 */ + , {0x00, 0xca, 0x95} + , {0x00, 0x00, 0x00} + , {0x00, 0x00, 0x00} + , {0x00, 0x00, 0x00} + } + , {DAC_PLUSTEK_3600, {0x70, 0x80, 0x00, 0x00} , {0x00, 0x00, 0x00} @@ -192,7 +208,7 @@ static Genesys_Frontend Wolfson[] = { {DAC_CS8400F, {0x00, 0x23, 0x24, 0x0f} , {0x00, 0x00, 0x00} - , {0x60, 0x5c, 0x6c} /* 0x20, 0x21, 0x22 */ + , {0x60, 0x5c, 0x6c} /* 0x20, 0x21, 0x22 */ , {0x8a, 0x9f, 0xc2} /* 0x28, 0x29, 0x2a */ , {0x00, 0x00, 0x00} } @@ -200,7 +216,7 @@ static Genesys_Frontend Wolfson[] = { {DAC_IMG101, {0x78, 0xf0, 0x00, 0x00} , {0x00, 0x00, 0x00} - , {0x00, 0x00, 0x00} /* 0x20, 0x21, 0x22 */ + , {0x00, 0x00, 0x00} /* 0x20, 0x21, 0x22 */ , {0x00, 0x00, 0x00} /* 0x28, 0x29, 0x2a */ , {0x00, 0x00, 0x00} } @@ -208,7 +224,7 @@ static Genesys_Frontend Wolfson[] = { {DAC_PLUSTEK3800, {0x78, 0xf0, 0x00, 0x00} , {0x00, 0x00, 0x00} - , {0x00, 0x00, 0x00} /* 0x20, 0x21, 0x22 */ + , {0x00, 0x00, 0x00} /* 0x20, 0x21, 0x22 */ , {0x00, 0x00, 0x00} /* 0x28, 0x29, 0x2a */ , {0x00, 0x00, 0x00} }, @@ -296,7 +312,7 @@ static Genesys_Sensor Sensor[] = { {CCD_HP2300, 600, 48, - 20, 0, 5368, 180, 180, /* 5376 */ + 20, 0, 5368, 180, 180, /* 5376 */ {0x16, 0x00, 0x01, 0x03} , {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0x0a, 0x20, 0x2a, 0x6a, 0x8a, 0x00, 0x05} , {0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x06, 0x0b, 0x10, 0x16} , @@ -307,21 +323,21 @@ static Genesys_Sensor Sensor[] = { /* CANOLIDE35 */ {CCD_CANONLIDE35, 1200, - 87, /* (black) */ - 87, /* (dummy) */ - 0, /* (startxoffset) */ - 10400, /* sensor_pixels */ + 87, /* (black) */ + 87, /* (dummy) */ + 0, /* (startxoffset) */ + 10400, /* sensor_pixels */ 0, 0, {0x00, 0x00, 0x00, 0x00}, {0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 0x50, - 0x00, 0x00, 0x00, 0x02 /* TODO(these do no harm, but may be neccessery for CCD) */ + 0x00, 0x00, 0x00, 0x02 /* TODO(these do no harm, but may be neccessery for CCD) */ }, {0x05, 0x07, - 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ + 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ 0x3a, 0x03, - 0x40, /*TODO: bit7 */ - 0x00, 0x00, 0x00, 0x00 /*TODO (these do no harm, but may be neccessery for CCD) */ + 0x40, /*TODO: bit7 */ + 0x00, 0x00, 0x00, 0x00 /*TODO (these do no harm, but may be neccessery for CCD) */ } , {1.0, 1.0, 1.0}, @@ -353,10 +369,10 @@ static Genesys_Sensor Sensor[] = { , /* Syscan DP 665 */ {CCD_DP665, 600, - 27, /*(black) */ - 27, /* (dummy) */ - 0, /* (startxoffset) */ - 2496, /*sensor_pixels */ + 27, /*(black) */ + 27, /* (dummy) */ + 0, /* (startxoffset) */ + 2496, /*sensor_pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -364,10 +380,10 @@ static Genesys_Sensor Sensor[] = { 0x10, 0x00, 0x20, 0x02 }, {0x04, 0x05, - 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ + 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ 0x54, 0x03, - 0x00, /*TODO: bit7 */ - 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ + 0x00, /*TODO: bit7 */ + 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ } , {1.0, 1.0, 1.0}, @@ -376,10 +392,10 @@ static Genesys_Sensor Sensor[] = { , /* Visioneer Roadwarrior */ {CCD_ROADWARRIOR, 600, - 27, /*(black) */ - 27, /* (dummy) */ - 0, /* (startxoffset) */ - 5200, /*sensor_pixels */ + 27, /*(black) */ + 27, /* (dummy) */ + 0, /* (startxoffset) */ + 5200, /*sensor_pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -387,10 +403,10 @@ static Genesys_Sensor Sensor[] = { 0x10, 0x00, 0x20, 0x02 }, {0x04, 0x05, - 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ + 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ 0x54, 0x03, - 0x00, /*TODO: bit7 */ - 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ + 0x00, /*TODO: bit7 */ + 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ } , {1.0, 1.0, 1.0}, @@ -399,10 +415,10 @@ static Genesys_Sensor Sensor[] = { , /* Pentax DS Mobile 600 */ {CCD_DSMOBILE600, 600, - 28, /*(black) */ - 28, /* (dummy) */ - 0, /* (startxoffset) */ - 5200, /*sensor_pixels */ + 28, /*(black) */ + 28, /* (dummy) */ + 0, /* (startxoffset) */ + 5200, /*sensor_pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -410,10 +426,10 @@ static Genesys_Sensor Sensor[] = { 0x10, 0x00, 0x20, 0x02 }, {0x04, 0x05, - 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ + 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ 0x54, 0x03, - 0x00, /*TODO: bit7 */ - 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ + 0x00, /*TODO: bit7 */ + 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ } , {1.0, 1.0, 1.0}, @@ -422,10 +438,10 @@ static Genesys_Sensor Sensor[] = { , /* 13: Strobe XP300 */ {CCD_XP300, 600, - 27, /*(black) */ - 27, /* (dummy) */ - 0, /* (startxoffset) */ - 10240, /*sensor_pixels */ + 27, /*(black) */ + 27, /* (dummy) */ + 0, /* (startxoffset) */ + 10240, /*sensor_pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -433,10 +449,10 @@ static Genesys_Sensor Sensor[] = { 0x10, 0x00, 0x20, 0x02 }, {0x04, 0x05, - 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ + 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ 0x54, 0x03, - 0x00, /*TODO: bit7 */ - 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ + 0x00, /*TODO: bit7 */ + 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ } , {1.0, 1.0, 1.0}, @@ -445,10 +461,10 @@ static Genesys_Sensor Sensor[] = { , /* 13: Strobe XP300 */ {CCD_DP685, 600, - 27, /*(black) */ - 27, /* (dummy) */ - 0, /* (startxoffset) */ - 5020, /*sensor_pixels */ + 27, /*(black) */ + 27, /* (dummy) */ + 0, /* (startxoffset) */ + 5020, /*sensor_pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -456,10 +472,10 @@ static Genesys_Sensor Sensor[] = { 0x10, 0x00, 0x20, 0x02 }, {0x04, 0x05, - 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ + 0x00, 0x00, 0x00, 0x00, /*[GB](HI|LOW) not needed for cis */ 0x54, 0x03, - 0x00, /*TODO: bit7 */ - 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ + 0x00, /*TODO: bit7 */ + 0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */ } , {1.0, 1.0, 1.0}, @@ -468,10 +484,10 @@ static Genesys_Sensor Sensor[] = { , /* CANONLIDE200 */ {CIS_CANONLIDE200, - 4800, /* optical resolution */ - 87*4, /* black pixels */ - 16*4, /* dummy pixels */ - 320*8, /* CCD_startx_offset 323 */ + 4800, /* optical resolution */ + 87*4, /* black pixels */ + 16*4, /* dummy pixels */ + 320*8, /* CCD_startx_offset 323 */ 5136*8, 210, 200, @@ -494,11 +510,11 @@ static Genesys_Sensor Sensor[] = { , /* CANONLIDE700 */ {CIS_CANONLIDE700, - 4800, /* optical resolution */ - 73*8, /* black pixels 73 at 600 dpi */ - 16*8, /* dummy pixels */ - 384*8, /* CCD_startx_offset 384 at 600 dpi */ - 5188*8, /* 8x5570 segments , 5187+1 for rounding */ + 4800, /* optical resolution */ + 73*8, /* black pixels 73 at 600 dpi */ + 16*8, /* dummy pixels */ + 384*8, /* CCD_startx_offset 384 at 600 dpi */ + 5188*8, /* 8x5570 segments , 5187+1 for rounding */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -520,10 +536,10 @@ static Genesys_Sensor Sensor[] = { , /* CANONLIDE100 */ {CIS_CANONLIDE100, - 2400, /* optical resolution */ - 87*4, /* black pixels */ - 16*4, /* dummy pixels 16 */ - 320*4, /* 323 */ + 2400, /* optical resolution */ + 87*4, /* black pixels */ + 16*4, /* dummy pixels 16 */ + 320*4, /* 323 */ 5136*4, /* 10272 */ 210, 200, @@ -565,8 +581,8 @@ static Genesys_Sensor Sensor[] = { , {CCD_G4050, 4800, - 50*8, /* black_pixels */ - 58, /* 31 at 600 dpi dummy_pixels 58 at 1200 */ + 50*8, /* black_pixels */ + 58, /* 31 at 600 dpi dummy_pixels 58 at 1200 */ 152, 5360*8, /* 5360 max at 600 dpi */ 160, @@ -583,8 +599,8 @@ static Genesys_Sensor Sensor[] = { , {CCD_CS4400F, 4800, - 50*8, /* black_pixels */ - 20, /* 31 at 600 dpi dummy_pixels 58 at 1200 */ + 50*8, /* black_pixels */ + 20, /* 31 at 600 dpi dummy_pixels 58 at 1200 */ 152, 5360*8, /* 5360 max at 600 dpi */ 160, @@ -601,8 +617,8 @@ static Genesys_Sensor Sensor[] = { , {CCD_CS8400F, 4800, - 50*8, /* black_pixels */ - 20, /* 31 at 600 dpi dummy_pixels 58 at 1200 */ + 50*8, /* black_pixels */ + 20, /* 31 at 600 dpi dummy_pixels 58 at 1200 */ 152, 5360*8, /* 5360 max at 600 dpi */ 160, @@ -639,11 +655,11 @@ static Genesys_Sensor Sensor[] = { /* CANONLIDE110 */ {CIS_CANONLIDE110, - 2400, /* optical resolution */ - 87, /* black pixels */ - 16, /* dummy pixels 16 */ - 303, /* 303 */ - 5168*4, /* total pixels */ + 2400, /* optical resolution */ + 87, /* black pixels */ + 16, /* dummy pixels 16 */ + 303, /* 303 */ + 5168*4, /* total pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -663,22 +679,25 @@ static Genesys_Sensor Sensor[] = { /* CANONLIDE120 */ {CIS_CANONLIDE120, - 2400, /* optical resolution */ - 87, /* black pixels */ - 16, /* dummy pixels 16 */ - 303, /* 303 */ - 5168*4, /* total pixels */ + 2400, /* optical resolution */ + 87, /* black pixels */ + 16, /* dummy pixels 16 */ + 303, + /* SEGCNT at 600 DPI by number of segments */ + 5104*4, /* total pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, /* reg 0x10 - 0x15 : EXPR, EXPG and EXPB */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* reg 0x16 - 0x1d */ - 0x10, 0x04, 0x00, 0x01, 0x30, 0x00, 0x02, 0x01 }, + 0x15, 0x04, 0x00, 0x01, 0x30, 0x00, 0x02, 0x01 }, /* reg 0x52 - 0x5e */ { - 0x00, 0x02, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, - 0x1a, 0x00, 0xc0, 0x00, 0x00 + /* 52 53 54 55 56 57 58 59 */ + 0x04, 0x06, 0x00, 0x02, 0x04, 0x04, 0x04, 0x04, + /* 5a 5b 5c 5d 5e */ + 0x3a, 0x00, 0x00, 0x00, 0x1f } , {2.1, 2.1, 2.1}, @@ -686,11 +705,11 @@ static Genesys_Sensor Sensor[] = { , /* CANON LIDE 210 sensor */ {CIS_CANONLIDE210, - 2400, /* optical resolution */ - 87, /* black pixels */ - 16, /* dummy pixels 16 */ - 303, /* 303 */ - 5168*4, /* total pixels */ + 2400, /* optical resolution */ + 87, /* black pixels */ + 16, /* dummy pixels 16 */ + 303, /* 303 */ + 5168*4, /* total pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -709,11 +728,11 @@ static Genesys_Sensor Sensor[] = { , /* CANON LIDE 220 sensor */ {CIS_CANONLIDE220, - 2400, /* optical resolution */ - 87, /* black pixels */ - 16, /* dummy pixels 16 */ - 303, /* 303 */ - 5168*4, /* total pixels */ + 2400, /* optical resolution */ + 87, /* black pixels */ + 16, /* dummy pixels 16 */ + 303, /* 303 */ + 5168*4, /* total pixels */ 210, 200, {0x00, 0x00, 0x00, 0x00}, @@ -732,21 +751,21 @@ static Genesys_Sensor Sensor[] = { , {CCD_PLUSTEK_3600, 1200, - 87, /*(black) */ - 87, /* (dummy) */ - 0, /* (startxoffset) */ - 10100, /*sensor_pixels */ + 87, /*(black) */ + 87, /* (dummy) */ + 0, /* (startxoffset) */ + 10100, /*sensor_pixels */ 210, 230, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x0b, 0x11, 0x2a, - 0x00, 0x00, 0x00, 0xc4 /* TODO(these do no harm, but may be neccessery for CCD) */ + 0x00, 0x00, 0x00, 0xc4 /* TODO(these do no harm, but may be neccessery for CCD) */ }, {0x07, 0x0a, - 0x0c, 0x00, 0x02, 0x06, /*[GB](HI|LOW) not needed for cis */ + 0x0c, 0x00, 0x02, 0x06, /*[GB](HI|LOW) not needed for cis */ 0x22, 0x69, - 0x40, /*TODO: bit7 */ - 0x00, 0x00, 0x00, 0x02 /*TODO (these do no harm, but may be neccessery for CCD) */ + 0x40, /*TODO: bit7 */ + 0x00, 0x00, 0x00, 0x02 /*TODO (these do no harm, but may be neccessery for CCD) */ } , {1.0, 1.0, 1.0}, @@ -754,7 +773,7 @@ static Genesys_Sensor Sensor[] = { , /* Canon Image formula 101 */ {CCD_IMG101, - 1200, /* optical resolution */ + 1200, /* optical resolution */ 31, 31, 0, @@ -781,7 +800,7 @@ static Genesys_Sensor Sensor[] = { , /* Plustek OpticBook 3800 */ {CCD_PLUSTEK3800, - 1200, /* optical resolution */ + 1200, /* optical resolution */ 31, 31, 0, @@ -857,7 +876,7 @@ static Genesys_Gpo Gpo[] = { /* MD5345/MD6471 */ {GPO_5345, {0x30, 0x18} - , /* bits 11-12 are for bipolar V-ref input voltage */ + , /* bits 11-12 are for bipolar V-ref input voltage */ {0xa0, 0x18} , } @@ -921,7 +940,7 @@ static Genesys_Gpo Gpo[] = { }, /* CANONLIDE200 */ {GPO_CANONLIDE200, - {0xfb, 0x20}, /* 0xfb when idle , 0xf9/0xe9 (1200) when scanning */ + {0xfb, 0x20}, /* 0xfb when idle , 0xf9/0xe9 (1200) when scanning */ {0xff, 0x00}, }, /* CANONLIDE700 */ @@ -951,6 +970,12 @@ static Genesys_Gpo Gpo[] = { {0xff, 0x00}, } , + /* CANONLIDE120 */ + {GPO_CANONLIDE120, + {0xfb, 0x20}, + {0xff, 0x00}, + } + , /* CANONLIDE210 */ {GPO_CANONLIDE210, {0xfb, 0x20}, @@ -997,15 +1022,15 @@ static Genesys_Gpo Gpo[] = { static Genesys_Motor Motor[] = { /* UMAX */ {MOTOR_UMAX, - 1200, /* motor base steps */ - 2400, /* maximum motor resolution */ - 1, /* maximum step mode */ + 1200, /* motor base steps */ + 2400, /* maximum motor resolution */ + 1, /* maximum step mode */ 1, /* number of power modes*/ {{{ - 11000, /* maximum start speed */ - 3000, /* maximum end speed */ - 128, /* step count */ - 1.0, /* nonlinearity */ + 11000, /* maximum start speed */ + 3000, /* maximum end speed */ + 128, /* step count */ + 1.0, /* nonlinearity */ }, { 11000, @@ -1014,7 +1039,7 @@ static Genesys_Motor Motor[] = { 1.0, },},}, }, - {MOTOR_5345, /* MD5345/6228/6471 */ + {MOTOR_5345, /* MD5345/6228/6471 */ 1200, 2400, 1, @@ -1032,7 +1057,7 @@ static Genesys_Motor Motor[] = { 0.5, },},}, }, - {MOTOR_ST24, /* ST24 */ + {MOTOR_ST24, /* ST24 */ 2400, 2400, 1, @@ -1050,15 +1075,15 @@ static Genesys_Motor Motor[] = { 0.3, },},}, }, - {MOTOR_HP3670, /* HP 3670 */ + {MOTOR_HP3670, /* HP 3670 */ 1200, 2400, 1, 1, {{{ - 11000, /* start speed */ - 3000, /* max speed */ - 128, /* min steps */ + 11000, /* start speed */ + 3000, /* max speed */ + 128, /* min steps */ 0.25, }, { @@ -1068,15 +1093,15 @@ static Genesys_Motor Motor[] = { 0.5, },},}, }, - {MOTOR_HP2400, /* HP 2400c */ + {MOTOR_HP2400, /* HP 2400c */ 1200, 1200, 1, 1, {{{ - 11000, /* start speed */ - 3000, /* max speed */ - 128, /* min steps */ + 11000, /* start speed */ + 3000, /* max speed */ + 128, /* min steps */ 0.25, }, { @@ -1086,7 +1111,7 @@ static Genesys_Motor Motor[] = { 0.5, },},}, }, - {MOTOR_HP2300, /* HP 2300c */ + {MOTOR_HP2300, /* HP 2300c */ 600, /* 600/1200 */ 1200, 1, @@ -1104,7 +1129,7 @@ static Genesys_Motor Motor[] = { 0.5, },},}, }, - {MOTOR_CANONLIDE35, /* Canon LiDE 35 */ + {MOTOR_CANONLIDE35, /* Canon LiDE 35 */ 1200, 2400, 1, @@ -1112,7 +1137,7 @@ static Genesys_Motor Motor[] = { {{{ 3500, 1300, 60, 0.8, }, { 3500, 1400, 60, 0.8, },},}, }, - {MOTOR_XP200, /* Strobe XP200 */ + {MOTOR_XP200, /* Strobe XP200 */ 600, 600, 1, @@ -1130,7 +1155,7 @@ static Genesys_Motor Motor[] = { 0.5, },},}, }, - {MOTOR_XP300, /* 7: Visioneer Strobe XP300 */ + {MOTOR_XP300, /* 7: Visioneer Strobe XP300 */ 300, 600, 1, @@ -1148,7 +1173,7 @@ static Genesys_Motor Motor[] = { 0.8, },},}, }, - {MOTOR_DP665, /* Syscan DP 665 */ + {MOTOR_DP665, /* Syscan DP 665 */ 750, 1500, 1, @@ -1166,7 +1191,7 @@ static Genesys_Motor Motor[] = { 0.8, },},}, }, - {MOTOR_ROADWARRIOR, /* Visioneer Roadwarrior */ + {MOTOR_ROADWARRIOR, /* Visioneer Roadwarrior */ 750, 1500, 1, @@ -1184,7 +1209,7 @@ static Genesys_Motor Motor[] = { 0.8, },},}, }, - {MOTOR_DSMOBILE_600, /* Pentax DSmobile 600 */ + {MOTOR_DSMOBILE_600, /* Pentax DSmobile 600 */ 750, 1500, 2, @@ -1202,7 +1227,7 @@ static Genesys_Motor Motor[] = { 0.8, },},}, }, - {MOTOR_CANONLIDE100, /* Canon LiDE 100 */ + {MOTOR_CANONLIDE100, /* Canon LiDE 100 */ 1200, 6400, 2, /* maximum step type count */ @@ -1210,12 +1235,12 @@ static Genesys_Motor Motor[] = { { /* motor slopes */ { /* power mode 0 */ { 3000, 1000, 127, 0.50}, /* full step */ - { 3000, 1500, 127, 0.50}, /* half step */ - { 3*2712, 3*2712, 16, 0.80}, /* quarter step 0.75*2712 */ + { 3000, 1500, 127, 0.50}, /* half step */ + { 3*2712, 3*2712, 16, 0.80}, /* quarter step 0.75*2712 */ }, }, }, - {MOTOR_CANONLIDE200, /* Canon LiDE 200 */ + {MOTOR_CANONLIDE200, /* Canon LiDE 200 */ 1200, 6400, 2, @@ -1223,12 +1248,12 @@ static Genesys_Motor Motor[] = { { /* motor slopes */ { /* power mode 0 */ { 3000, 1000, 127, 0.50}, /* full step */ - { 3000, 1500, 127, 0.50}, /* half step */ - { 3*2712, 3*2712, 16, 0.80}, /* quarter step 0.75*2712 */ + { 3000, 1500, 127, 0.50}, /* half step */ + { 3*2712, 3*2712, 16, 0.80}, /* quarter step 0.75*2712 */ }, }, }, - {MOTOR_CANONLIDE700, /* Canon LiDE 700 */ + {MOTOR_CANONLIDE700, /* Canon LiDE 700 */ 1200, 6400, 2, @@ -1236,8 +1261,8 @@ static Genesys_Motor Motor[] = { { /* motor slopes */ { /* power mode 0 */ { 3000, 1000, 127, 0.50}, /* full step */ - { 3000, 1500, 127, 0.50}, /* half step */ - { 3*2712, 3*2712, 16, 0.80}, /* quarter step 0.75*2712 */ + { 3000, 1500, 127, 0.50}, /* half step */ + { 3*2712, 3*2712, 16, 0.80}, /* quarter step 0.75*2712 */ }, }, }, @@ -1248,10 +1273,10 @@ static Genesys_Motor Motor[] = { 1, { /* motor slopes */ { /* power mode 0 */ - { 22222, 500, 246, 0.5 }, /* max speed / dpi * base dpi => exposure */ - { 22222, 500, 246, 0.5 }, - { 22222, 500, 246, 0.5 }, - }, + { 22222, 500, 246, 0.5 }, /* max speed / dpi * base dpi => exposure */ + { 22222, 500, 246, 0.5 }, + { 22222, 500, 246, 0.5 }, + }, }, }, {MOTOR_G4050, @@ -1261,10 +1286,10 @@ static Genesys_Motor Motor[] = { 1, { /* motor slopes */ { /* power mode 0 */ - { 3961, 240, 246, 0.8 }, /* full step */ - { 3961, 240, 246, 0.8 }, /* half step */ - { 3961, 240, 246, 0.8 }, /* quarter step */ - }, + { 3961, 240, 246, 0.8 }, /* full step */ + { 3961, 240, 246, 0.8 }, /* half step */ + { 3961, 240, 246, 0.8 }, /* quarter step */ + }, }, }, {MOTOR_CS8400F, @@ -1274,13 +1299,13 @@ static Genesys_Motor Motor[] = { 1, { /* motor slopes */ { /* power mode 0 */ - { 3961, 240, 246, 0.8 }, /* full step */ - { 3961, 240, 246, 0.8 }, /* half step */ - { 3961, 240, 246, 0.8 }, /* quarter step */ - }, + { 3961, 240, 246, 0.8 }, /* full step */ + { 3961, 240, 246, 0.8 }, /* half step */ + { 3961, 240, 246, 0.8 }, /* quarter step */ + }, }, }, - {MOTOR_CANONLIDE110, /* Canon LiDE 110 */ + {MOTOR_CANONLIDE110, /* Canon LiDE 110 */ 4800, 9600, 1, /* maximum step type count */ @@ -1291,7 +1316,7 @@ static Genesys_Motor Motor[] = { }, }, }, - {MOTOR_CANONLIDE210, /* Canon LiDE 210 */ + {MOTOR_CANONLIDE120, /* Canon LiDE 120 */ 4800, 9600, 1, /* maximum step type count */ @@ -1302,7 +1327,18 @@ static Genesys_Motor Motor[] = { }, }, }, - {MOTOR_PLUSTEK_3600, /* PLUSTEK 3600 */ + {MOTOR_CANONLIDE210, /* Canon LiDE 210 */ + 4800, + 9600, + 1, /* maximum step type count */ + 1, /* maximum power modes count */ + { /* motor slopes */ + { /* power mode 0 */ + { 3000, 1000, 256, 0.50}, /* full step */ + }, + }, + }, + {MOTOR_PLUSTEK_3600, /* PLUSTEK 3600 */ 1200, 2400, 1, @@ -1313,7 +1349,7 @@ static Genesys_Motor Motor[] = { { 3500, 3250, 60, 0.8 }, }, },}, - {MOTOR_IMG101, /* Canon Image Formula 101 */ + {MOTOR_IMG101, /* Canon Image Formula 101 */ 600, 1200, 1, @@ -1324,7 +1360,7 @@ static Genesys_Motor Motor[] = { { 3500, 3250, 60, 0.8 }, }, },}, - {MOTOR_PLUSTEK3800, /* Plustek OpticBook 3800 */ + {MOTOR_PLUSTEK3800, /* Plustek OpticBook 3800 */ 600, 1200, 1, @@ -1338,8 +1374,8 @@ static Genesys_Motor Motor[] = { {MOTOR_CANONLIDE80, 2400, /* 2400 ???? */ 4800, /* 9600 ???? */ - 1, /* max step type */ - 1, /* power mode count */ + 1, /* max step type */ + 1, /* power mode count */ { { /* start speed, max end speed, step number */ /* maximum speed (second field) is used to compute exposure as seen by motor */ @@ -1355,48 +1391,48 @@ static Genesys_Motor Motor[] = { /* here we have the various device settings... */ static Genesys_Model umax_astra_4500_model = { - "umax-astra-4500", /* Name */ - "UMAX", /* Device vendor string */ - "Astra 4500", /* Device model name */ + "umax-astra-4500", /* Name */ + "UMAX", /* Device vendor string */ + "Astra 4500", /* Device model name */ GENESYS_GL646, NULL, - {1200, 600, 300, 150, 75, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 300, 150, 75, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (3.5), /* Start of scan area in mm (x) */ - SANE_FIX (7.5), /* Start of scan area in mm (y) */ - SANE_FIX (218.0), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (3.5), /* Start of scan area in mm (x) */ + SANE_FIX (7.5), /* Start of scan area in mm (y) */ + SANE_FIX (218.0), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (1.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (1.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ + 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ + COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_UMAX, DAC_WOLFSON_UMAX, GPO_UMAX, MOTOR_UMAX, - GENESYS_FLAG_UNTESTED, /* Which flags are needed for this scanner? */ + GENESYS_FLAG_UNTESTED, /* Which flags are needed for this scanner? */ /* untested, values set by hmg */ GENESYS_HAS_NO_BUTTONS, /* no buttons supported */ 20, @@ -1404,48 +1440,48 @@ static Genesys_Model umax_astra_4500_model = { }; static Genesys_Model canon_lide_50_model = { - "canon-lide-50", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 35/40/50", /* Device model name */ + "canon-lide-50", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 35/40/50", /* Device model name */ GENESYS_GL841, NULL, - { 1200, 600, 400, 300, 240, 200, 150, 75, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 400, 300, 240, 200, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + { 1200, 600, 400, 300, 240, 200, 150, 75, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 400, 300, 240, 200, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.42), /* Start of scan area in mm (x) */ - SANE_FIX (7.9), /* Start of scan area in mm (y) */ - SANE_FIX (218.0), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (0.42), /* Start of scan area in mm (x) */ + SANE_FIX (7.9), /* Start of scan area in mm (y) */ + SANE_FIX (218.0), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (6.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (6.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_CANONLIDE35, DAC_CANONLIDE35, GPO_CANONLIDE35, MOTOR_CANONLIDE35, - GENESYS_FLAG_LAZY_INIT | /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT | /* Which flags are needed for this scanner? */ GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION | @@ -1460,43 +1496,43 @@ static Genesys_Model canon_lide_50_model = { }; static Genesys_Model panasonic_kvss080_model = { - "panasonic-kv-ss080", /* Name */ - "Panasonic", /* Device vendor string */ - "KV-SS080", /* Device model name */ + "panasonic-kv-ss080", /* Name */ + "Panasonic", /* Device vendor string */ + "KV-SS080", /* Device model name */ GENESYS_GL843, NULL, - { 600, /* 500, 400,*/ 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ - { 1200, 600, /* 500, 400, */ 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + { 600, /* 500, 400,*/ 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ + { 1200, 600, /* 500, 400, */ 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (7.2), /* Start of scan area in mm (x) */ - SANE_FIX (14.7), /* Start of scan area in mm (y) */ - SANE_FIX (217.7), /* Size of scan area in mm (x) */ - SANE_FIX (300.0), /* Size of scan area in mm (y) */ + SANE_FIX (7.2), /* Start of scan area in mm (x) */ + SANE_FIX (14.7), /* Start of scan area in mm (y) */ + SANE_FIX (217.7), /* Size of scan area in mm (x) */ + SANE_FIX (300.0), /* Size of scan area in mm (y) */ - SANE_FIX (9.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (9.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ + 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_KVSS080, DAC_KVSS080, GPO_KVSS080, @@ -1511,45 +1547,45 @@ static Genesys_Model panasonic_kvss080_model = { }; static Genesys_Model hp4850c_model = { - "hewlett-packard-scanjet-4850c", /* Name */ - "Hewlett Packard", /* Device vendor string */ - "ScanJet 4850C", /* Device model name */ + "hewlett-packard-scanjet-4850c", /* Name */ + "Hewlett Packard", /* Device vendor string */ + "ScanJet 4850C", /* Device model name */ GENESYS_GL843, NULL, {2400, 1200, 600, 400, 300, 200, 150, 100, 0}, {2400, 1200, 600, 400, 300, 200, 150, 100, 0}, - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ SANE_FIX (7.9), /* Start of scan area in mm (x) */ SANE_FIX (5.9), /* Start of scan area in mm (y) */ SANE_FIX (219.6), /* Size of scan area in mm (x) */ SANE_FIX (314.5), /* Size of scan area in mm (y) */ - SANE_FIX (3.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (3.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in line number */ - /* 0 38 76 OK 1200/2400 */ - /* 0 24 48 OK [100,600] dpi */ + 0, 24, 48, /* RGB CCD Line-distance correction in line number */ + /* 0 38 76 OK 1200/2400 */ + /* 0 24 48 OK [100,600] dpi */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_G4050, DAC_G4050, GPO_G4050, @@ -1566,45 +1602,45 @@ static Genesys_Model hp4850c_model = { }; static Genesys_Model hpg4010_model = { - "hewlett-packard-scanjet-g4010", /* Name */ - "Hewlett Packard", /* Device vendor string */ - "ScanJet G4010", /* Device model name */ + "hewlett-packard-scanjet-g4010", /* Name */ + "Hewlett Packard", /* Device vendor string */ + "ScanJet G4010", /* Device model name */ GENESYS_GL843, NULL, { 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, { 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (8.0), /* Start of scan area in mm (x) */ - SANE_FIX (13.00), /* Start of scan area in mm (y) */ - SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ - SANE_FIX (315.0), /* Size of scan area in mm (y) */ + SANE_FIX (8.0), /* Start of scan area in mm (x) */ + SANE_FIX (13.00), /* Start of scan area in mm (y) */ + SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ + SANE_FIX (315.0), /* Size of scan area in mm (y) */ - SANE_FIX (3.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (3.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in line number */ - /* 0 38 76 OK 1200/2400 */ - /* 0 24 48 OK [100,600] dpi */ + 0, 24, 48, /* RGB CCD Line-distance correction in line number */ + /* 0 38 76 OK 1200/2400 */ + /* 0 24 48 OK [100,600] dpi */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_G4050, DAC_G4050, GPO_G4050, @@ -1621,45 +1657,45 @@ static Genesys_Model hpg4010_model = { }; static Genesys_Model hpg4050_model = { - "hewlett-packard-scanjet-g4050", /* Name */ - "Hewlett Packard", /* Device vendor string */ - "ScanJet G4050", /* Device model name */ + "hewlett-packard-scanjet-g4050", /* Name */ + "Hewlett Packard", /* Device vendor string */ + "ScanJet G4050", /* Device model name */ GENESYS_GL843, NULL, { 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, { 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (8.0), /* Start of scan area in mm (x) */ - SANE_FIX (13.00), /* Start of scan area in mm (y) */ - SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ - SANE_FIX (315.0), /* Size of scan area in mm (y) */ + SANE_FIX (8.0), /* Start of scan area in mm (x) */ + SANE_FIX (13.00), /* Start of scan area in mm (y) */ + SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ + SANE_FIX (315.0), /* Size of scan area in mm (y) */ - SANE_FIX (3.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (3.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (8.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (13.00), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (217.9), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (250.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (8.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (13.00), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (217.9), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (250.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in line number */ - /* 0 38 76 OK 1200/2400 */ - /* 0 24 48 OK [100,600] dpi */ + 0, 24, 48, /* RGB CCD Line-distance correction in line number */ + /* 0 38 76 OK 1200/2400 */ + /* 0 24 48 OK [100,600] dpi */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_G4050, DAC_G4050, GPO_G4050, @@ -1677,45 +1713,45 @@ static Genesys_Model hpg4050_model = { static Genesys_Model canon_4400f_model = { - "canon-canoscan-4400f", /* Name */ - "Canon", /* Device vendor string */ - "Canoscan 4400f", /* Device model name */ + "canon-canoscan-4400f", /* Name */ + "Canon", /* Device vendor string */ + "Canoscan 4400f", /* Device model name */ GENESYS_GL843, NULL, { 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, { 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (6.0), /* Start of scan area in mm (x) */ - SANE_FIX (13.00), /* Start of scan area in mm (y) */ - SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ - SANE_FIX (315.0), /* Size of scan area in mm (y) */ + SANE_FIX (6.0), /* Start of scan area in mm (x) */ + SANE_FIX (13.00), /* Start of scan area in mm (y) */ + SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ + SANE_FIX (315.0), /* Size of scan area in mm (y) */ - SANE_FIX (3.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (3.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (8.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (13.00), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (217.9), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (250.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (8.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (13.00), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (217.9), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (250.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in line number */ - /* 0 38 76 OK 1200/2400 */ - /* 0 24 48 OK [100,600] dpi */ + 0, 24, 48, /* RGB CCD Line-distance correction in line number */ + /* 0 38 76 OK 1200/2400 */ + /* 0 24 48 OK [100,600] dpi */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_CS4400F, DAC_G4050, GPO_CS4400F, @@ -1727,7 +1763,7 @@ static Genesys_Model canon_4400f_model = { GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_FULL_HWDPI_MODE | - GENESYS_FLAG_HALF_CCD_MODE | /* actually quarter CCD mode ... */ + GENESYS_FLAG_HALF_CCD_MODE | /* actually quarter CCD mode ... */ GENESYS_FLAG_CUSTOM_GAMMA, GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW, 100, @@ -1736,45 +1772,45 @@ static Genesys_Model canon_4400f_model = { static Genesys_Model canon_8400f_model = { - "canon-canoscan-8400f", /* Name */ - "Canon", /* Device vendor string */ - "Canoscan 8400f", /* Device model name */ + "canon-canoscan-8400f", /* Name */ + "Canon", /* Device vendor string */ + "Canoscan 8400f", /* Device model name */ GENESYS_GL843, NULL, { 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, { 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 0}, - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (4.0), /* Start of scan area in mm (x) */ - SANE_FIX (13.00), /* Start of scan area in mm (y) */ - SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ - SANE_FIX (315.0), /* Size of scan area in mm (y) */ + SANE_FIX (4.0), /* Start of scan area in mm (x) */ + SANE_FIX (13.00), /* Start of scan area in mm (y) */ + SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ + SANE_FIX (315.0), /* Size of scan area in mm (y) */ - SANE_FIX (3.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (3.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (8.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (13.00), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (217.9), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (250.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (8.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (13.00), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (217.9), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (250.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in line number */ - /* 0 38 76 OK 1200/2400 */ - /* 0 24 48 OK [100,600] dpi */ + 0, 24, 48, /* RGB CCD Line-distance correction in line number */ + /* 0 38 76 OK 1200/2400 */ + /* 0 24 48 OK [100,600] dpi */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_CS8400F, DAC_CS8400F, GPO_CS8400F, @@ -1795,43 +1831,43 @@ static Genesys_Model canon_8400f_model = { static Genesys_Model canon_lide_100_model = { - "canon-lide-100", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 100", /* Device model name */ + "canon-lide-100", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 100", /* Device model name */ GENESYS_GL847, NULL, - {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ - {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ + {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (1.1), /* Start of scan area in mm (x) */ - SANE_FIX (8.3), /* Start of scan area in mm (y) */ - SANE_FIX (216.07), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (1.1), /* Start of scan area in mm (x) */ + SANE_FIX (8.3), /* Start of scan area in mm (y) */ + SANE_FIX (216.07), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (1.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (1.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE100, DAC_CANONLIDE200, GPO_CANONLIDE200, @@ -1849,43 +1885,43 @@ static Genesys_Model canon_lide_100_model = { }; static Genesys_Model canon_lide_110_model = { - "canon-lide-110", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 110", /* Device model name */ + "canon-lide-110", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 110", /* Device model name */ GENESYS_GL124, NULL, - {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible x-resolutions */ - {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible x-resolutions */ + {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (2.2), /* Start of scan area in mm (x) */ - SANE_FIX (9.0), /* Start of scan area in mm (y) */ - SANE_FIX (216.70), /* Size of scan area in mm (x) */ - SANE_FIX (300.0), /* Size of scan area in mm (y) */ + SANE_FIX (2.2), /* Start of scan area in mm (x) */ + SANE_FIX (9.0), /* Start of scan area in mm (y) */ + SANE_FIX (216.70), /* Size of scan area in mm (x) */ + SANE_FIX (300.0), /* Size of scan area in mm (y) */ - SANE_FIX (1.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (1.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE110, DAC_CANONLIDE110, GPO_CANONLIDE110, @@ -1902,47 +1938,47 @@ static Genesys_Model canon_lide_110_model = { }; static Genesys_Model canon_lide_120_model = { - "canon-lide-120", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 120", /* Device model name */ + "canon-lide-120", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 120", /* Device model name */ GENESYS_GL124, NULL, - {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ - {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ + {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (2.2), /* Start of scan area in mm (x) */ - SANE_FIX (9.0), /* Start of scan area in mm (y) */ - SANE_FIX (216.70), /* Size of scan area in mm (x) */ - SANE_FIX (300.0), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (8.0), /* Start of scan area in mm (y) */ + SANE_FIX (216.0), /* Size of scan area in mm (x) */ + SANE_FIX (300.0), /* Size of scan area in mm (y) */ - SANE_FIX (1.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (1.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE120, - DAC_CANONLIDE110, - GPO_CANONLIDE110, - MOTOR_CANONLIDE110, + DAC_CANONLIDE120, + GPO_CANONLIDE120, + MOTOR_CANONLIDE120, GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION @@ -1956,43 +1992,43 @@ static Genesys_Model canon_lide_120_model = { static Genesys_Model canon_lide_210_model = { - "canon-lide-210", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 210", /* Device model name */ + "canon-lide-210", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 210", /* Device model name */ GENESYS_GL124, NULL, - {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible x-resolutions */ - {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible x-resolutions */ + {4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (2.2), /* Start of scan area in mm (x) */ - SANE_FIX (8.7), /* Start of scan area in mm (y) */ - SANE_FIX (216.70), /* Size of scan area in mm (x) */ - SANE_FIX (297.5), /* Size of scan area in mm (y) */ + SANE_FIX (2.2), /* Start of scan area in mm (x) */ + SANE_FIX (8.7), /* Start of scan area in mm (y) */ + SANE_FIX (216.70), /* Size of scan area in mm (x) */ + SANE_FIX (297.5), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE210, DAC_CANONLIDE110, GPO_CANONLIDE210, @@ -2009,43 +2045,43 @@ static Genesys_Model canon_lide_210_model = { }; static Genesys_Model canon_lide_220_model = { - "canon-lide-220", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 220", /* Device model name */ + "canon-lide-220", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 220", /* Device model name */ GENESYS_GL124, /* or a compatible one */ NULL, - {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ - {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ + {4800, 2400, 1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (2.2), /* Start of scan area in mm (x) */ - SANE_FIX (8.7), /* Start of scan area in mm (y) */ - SANE_FIX (216.70), /* Size of scan area in mm (x) */ - SANE_FIX (297.5), /* Size of scan area in mm (y) */ + SANE_FIX (2.2), /* Start of scan area in mm (x) */ + SANE_FIX (8.7), /* Start of scan area in mm (y) */ + SANE_FIX (216.70), /* Size of scan area in mm (x) */ + SANE_FIX (297.5), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE220, DAC_CANONLIDE110, GPO_CANONLIDE210, @@ -2062,48 +2098,48 @@ static Genesys_Model canon_lide_220_model = { }; static Genesys_Model canon_5600f_model = { - "canon-5600f", /* Name */ - "Canon", /* Device vendor string */ - "5600F", /* Device model name */ + "canon-5600f", /* Name */ + "Canon", /* Device vendor string */ + "5600F", /* Device model name */ GENESYS_GL847, NULL, - {1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ - {1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ + {1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (1.1), /* Start of scan area in mm (x) */ - SANE_FIX (8.3), /* Start of scan area in mm (y) */ - SANE_FIX (216.07), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (1.1), /* Start of scan area in mm (x) */ + SANE_FIX (8.3), /* Start of scan area in mm (y) */ + SANE_FIX (216.07), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (3.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (3.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE200, DAC_CANONLIDE200, GPO_CANONLIDE200, MOTOR_CANONLIDE200, - GENESYS_FLAG_UNTESTED /* not working yet */ + GENESYS_FLAG_UNTESTED /* not working yet */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_SIS_SENSOR | GENESYS_FLAG_DARK_CALIBRATION @@ -2115,43 +2151,43 @@ static Genesys_Model canon_5600f_model = { }; static Genesys_Model canon_lide_700f_model = { - "canon-lide-700f", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 700F", /* Device model name */ + "canon-lide-700f", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 700F", /* Device model name */ GENESYS_GL847, NULL, - {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ - {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ + {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (3.1), /* Start of scan area in mm (x) */ - SANE_FIX (8.1), /* Start of scan area in mm (y) */ - SANE_FIX (216.07), /* Size of scan area in mm (x) */ - SANE_FIX (297.0), /* Size of scan area in mm (y) */ + SANE_FIX (3.1), /* Start of scan area in mm (x) */ + SANE_FIX (8.1), /* Start of scan area in mm (y) */ + SANE_FIX (216.07), /* Size of scan area in mm (x) */ + SANE_FIX (297.0), /* Size of scan area in mm (y) */ - SANE_FIX (1.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (1.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE700, DAC_CANONLIDE700, GPO_CANONLIDE700, @@ -2170,43 +2206,43 @@ static Genesys_Model canon_lide_700f_model = { static Genesys_Model canon_lide_200_model = { - "canon-lide-200", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 200", /* Device model name */ + "canon-lide-200", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 200", /* Device model name */ GENESYS_GL847, NULL, - {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ - {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ + {4800, 2400, 1200, 600, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (1.1), /* Start of scan area in mm (x) */ - SANE_FIX (8.3), /* Start of scan area in mm (y) */ - SANE_FIX (216.07), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (1.1), /* Start of scan area in mm (x) */ + SANE_FIX (8.3), /* Start of scan area in mm (y) */ + SANE_FIX (216.07), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE200, DAC_CANONLIDE200, GPO_CANONLIDE200, @@ -2224,48 +2260,48 @@ static Genesys_Model canon_lide_200_model = { static Genesys_Model canon_lide_60_model = { - "canon-lide-60", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 60", /* Device model name */ + "canon-lide-60", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 60", /* Device model name */ GENESYS_GL841, NULL, - {1200, 600, 300, 150, 75, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 300, 150, 75, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.42), /* Start of scan area in mm (x) */ - SANE_FIX (7.9), /* Start of scan area in mm (y) */ - SANE_FIX (218.0), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (0.42), /* Start of scan area in mm (x) */ + SANE_FIX (7.9), /* Start of scan area in mm (y) */ + SANE_FIX (218.0), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (6.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (6.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_CANONLIDE35, DAC_CANONLIDE35, GPO_CANONLIDE35, MOTOR_CANONLIDE35, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION @@ -2275,50 +2311,50 @@ static Genesys_Model canon_lide_60_model = { GENESYS_HAS_NO_BUTTONS, /* no buttons supported */ 300, 400 -}; /* this is completely untested -- hmg */ +}; /* this is completely untested -- hmg */ static Genesys_Model canon_lide_80_model = { - "canon-lide-80", /* Name */ - "Canon", /* Device vendor string */ - "LiDE 80", /* Device model name */ + "canon-lide-80", /* Name */ + "Canon", /* Device vendor string */ + "LiDE 80", /* Device model name */ GENESYS_GL841, NULL, - { 1200, 600, 400, 300, 240, 150, 100, 75, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 400, 300, 240, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.42), /* Start of scan area in mm (x) 0.42 */ - SANE_FIX (7.90), /* Start of scan area in mm (y) 7.90 */ - SANE_FIX (216.07), /* Size of scan area in mm (x) 218.00 */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + { 1200, 600, 400, 300, 240, 150, 100, 75, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 400, 300, 240, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ + SANE_FIX (0.42), /* Start of scan area in mm (x) 0.42 */ + SANE_FIX (7.90), /* Start of scan area in mm (y) 7.90 */ + SANE_FIX (216.07), /* Size of scan area in mm (x) 218.00 */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (4.5), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (4.5), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CIS_CANONLIDE80, DAC_CANONLIDE80, GPO_CANONLIDE80, MOTOR_CANONLIDE80, - GENESYS_FLAG_LAZY_INIT | /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT | /* Which flags are needed for this scanner? */ GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION | @@ -2334,43 +2370,43 @@ static Genesys_Model canon_lide_80_model = { static Genesys_Model hp2300c_model = { - "hewlett-packard-scanjet-2300c", /* Name */ - "Hewlett Packard", /* Device vendor string */ - "ScanJet 2300c", /* Device model name */ + "hewlett-packard-scanjet-2300c", /* Name */ + "Hewlett Packard", /* Device vendor string */ + "ScanJet 2300c", /* Device model name */ GENESYS_GL646, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions, motor can go up to 1200 dpi */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions, motor can go up to 1200 dpi */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (2.0), /* Start of scan area in mm (x_offset) */ - SANE_FIX (7.5), /* Start of scan area in mm (y_offset) */ - SANE_FIX (215.9), /* Size of scan area in mm (x) */ - SANE_FIX (295.0), /* Size of scan area in mm (y) */ + SANE_FIX (2.0), /* Start of scan area in mm (x_offset) */ + SANE_FIX (7.5), /* Start of scan area in mm (y_offset) */ + SANE_FIX (215.9), /* Size of scan area in mm (x) */ + SANE_FIX (295.0), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (1.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (1.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 16, 8, 0, /* RGB CCD Line-distance correction in pixel */ + 16, 8, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_HP2300, DAC_WOLFSON_HP2300, GPO_HP2300, @@ -2390,43 +2426,43 @@ static Genesys_Model hp2300c_model = { static Genesys_Model hp2400c_model = { - "hewlett-packard-scanjet-2400c", /* Name */ - "Hewlett Packard", /* Device vendor string */ - "ScanJet 2400c", /* Device model name */ + "hewlett-packard-scanjet-2400c", /* Name */ + "Hewlett Packard", /* Device vendor string */ + "ScanJet 2400c", /* Device model name */ GENESYS_GL646, NULL, - {1200, 600, 300, 150, 100, 50, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 100, 50, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 300, 150, 100, 50, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 100, 50, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (6.5), /* Start of scan area in mm (x) */ - SANE_FIX (2.5), /* Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (297.2), /* Size of scan area in mm (y) */ + SANE_FIX (6.5), /* Start of scan area in mm (x) */ + SANE_FIX (2.5), /* Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (297.2), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (1.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (1.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ + 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_HP2400, DAC_WOLFSON_HP2400, GPO_HP2400, @@ -2445,45 +2481,45 @@ Genesys_Model hp2400c_model = { static Genesys_Model visioneer_xp200_model = { - "visioneer-strobe-xp200", /* Name */ - "Visioneer", /* Device vendor string */ - "Strobe XP200", /* Device model name */ + "visioneer-strobe-xp200", /* Name */ + "Visioneer", /* Device vendor string */ + "Strobe XP200", /* Device model name */ GENESYS_GL646, NULL, - {600, 300, 200, 100, 75, 0}, /* possible x-resolutions */ - {600, 300, 200, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 200, 100, 75, 0}, /* possible x-resolutions */ + {600, 300, 200, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.5), /* Start of scan area in mm (x) */ - SANE_FIX (16.0), /* Start of scan area in mm (y) */ - SANE_FIX (215.9), /* Size of scan area in mm (x) */ - SANE_FIX (297.2), /* Size of scan area in mm (y) */ + SANE_FIX (0.5), /* Start of scan area in mm (x) */ + SANE_FIX (16.0), /* Start of scan area in mm (y) */ + SANE_FIX (215.9), /* Size of scan area in mm (x) */ + SANE_FIX (297.2), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CIS_XP200, - DAC_AD_XP200, /* Analog Device frontend */ + DAC_AD_XP200, /* Analog Device frontend */ GPO_XP200, MOTOR_XP200, GENESYS_FLAG_14BIT_GAMMA @@ -2498,43 +2534,43 @@ Genesys_Model visioneer_xp200_model = { }; static Genesys_Model hp3670c_model = { - "hewlett-packard-scanjet-3670c", /* Name */ - "Hewlett Packard", /* Device vendor string */ - "ScanJet 3670c", /* Device model name */ + "hewlett-packard-scanjet-3670c", /* Name */ + "Hewlett Packard", /* Device vendor string */ + "ScanJet 3670c", /* Device model name */ GENESYS_GL646, NULL, - {1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (8.5), /* Start of scan area in mm (x) */ - SANE_FIX (11.0), /* Start of scan area in mm (y) */ - SANE_FIX (215.9), /* Size of scan area in mm (x) */ - SANE_FIX (300.0), /* Size of scan area in mm (y) */ + SANE_FIX (8.5), /* Start of scan area in mm (x) */ + SANE_FIX (11.0), /* Start of scan area in mm (y) */ + SANE_FIX (215.9), /* Size of scan area in mm (x) */ + SANE_FIX (300.0), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (1.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (1.0), /* Start of black mark in mm (x) */ - SANE_FIX (104.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (55.6), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (25.6), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (78.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (104.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (55.6), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (25.6), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (78.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (76.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (76.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ + 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_HP3670, DAC_WOLFSON_HP3670, GPO_HP3670, @@ -2552,91 +2588,91 @@ static Genesys_Model hp3670c_model = { }; static Genesys_Model plustek_st12_model = { - "plustek-opticpro-st12", /* Name */ - "Plustek", /* Device vendor string */ - "OpticPro ST12", /* Device model name */ + "plustek-opticpro-st12", /* Name */ + "Plustek", /* Device vendor string */ + "OpticPro ST12", /* Device model name */ GENESYS_GL646, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (3.5), /* Start of scan area in mm (x) */ - SANE_FIX (7.5), /* Start of scan area in mm (y) */ - SANE_FIX (218.0), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (3.5), /* Start of scan area in mm (x) */ + SANE_FIX (7.5), /* Start of scan area in mm (y) */ + SANE_FIX (218.0), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (1.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (1.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ + 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ + COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_ST12, DAC_WOLFSON_ST12, GPO_ST12, MOTOR_UMAX, - GENESYS_FLAG_UNTESTED | GENESYS_FLAG_14BIT_GAMMA, /* Which flags are needed for this scanner? */ + GENESYS_FLAG_UNTESTED | GENESYS_FLAG_14BIT_GAMMA, /* Which flags are needed for this scanner? */ GENESYS_HAS_NO_BUTTONS, /* no buttons supported */ 20, 200 }; static Genesys_Model plustek_st24_model = { - "plustek-opticpro-st24", /* Name */ - "Plustek", /* Device vendor string */ - "OpticPro ST24", /* Device model name */ + "plustek-opticpro-st24", /* Name */ + "Plustek", /* Device vendor string */ + "OpticPro ST24", /* Device model name */ GENESYS_GL646, NULL, - {1200, 600, 300, 150, 75, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 300, 150, 75, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (3.5), /* Start of scan area in mm (x) */ - SANE_FIX (7.5), /* Start of scan area in mm (y) */ - SANE_FIX (218.0), /* Size of scan area in mm (x) */ - SANE_FIX (299.0), /* Size of scan area in mm (y) */ + SANE_FIX (3.5), /* Start of scan area in mm (x) */ + SANE_FIX (7.5), /* Start of scan area in mm (y) */ + SANE_FIX (218.0), /* Size of scan area in mm (x) */ + SANE_FIX (299.0), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (1.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (1.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ + 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ + COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_ST24, DAC_WOLFSON_ST24, GPO_ST24, @@ -2653,42 +2689,42 @@ static Genesys_Model plustek_st24_model = { }; static Genesys_Model medion_md5345_model = { - "medion-md5345-model", /* Name */ - "Medion", /* Device vendor string */ - "MD5345/MD6228/MD6471", /* Device model name */ + "medion-md5345-model", /* Name */ + "Medion", /* Device vendor string */ + "MD5345/MD6228/MD6471", /* Device model name */ GENESYS_GL646, NULL, - {1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX ( 0.30), /* Start of scan area in mm (x) */ - SANE_FIX ( 0.80), /* 2.79 < Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (296.4), /* Size of scan area in mm (y) */ + SANE_FIX ( 0.30), /* Start of scan area in mm (x) */ + SANE_FIX ( 0.80), /* 2.79 < Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (296.4), /* Size of scan area in mm (y) */ - SANE_FIX (0.00), /* Start of white strip in mm (y) */ - SANE_FIX (0.00), /* Start of black mark in mm (x) */ + SANE_FIX (0.00), /* Start of white strip in mm (y) */ + SANE_FIX (0.00), /* Start of black mark in mm (x) */ - SANE_FIX (0.00), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.00), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (0.00), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (0.00), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.00), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.00), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (0.00), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (0.00), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.00), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.00), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_5345, DAC_WOLFSON_5345, GPO_5345, @@ -2708,49 +2744,49 @@ static Genesys_Model medion_md5345_model = { }; static Genesys_Model visioneer_xp300_model = { - "visioneer-strobe-xp300", /* Name */ - "Visioneer", /* Device vendor string */ - "Strobe XP300", /* Device model name */ + "visioneer-strobe-xp300", /* Name */ + "Visioneer", /* Device vendor string */ + "Strobe XP300", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (1.0), /* Start of scan area in mm (y) */ - SANE_FIX (435.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (1.0), /* Start of scan area in mm (y) */ + SANE_FIX (435.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (26.5), /* Size of scan area after paper sensor stops + SANE_FIX (26.5), /* Size of scan area after paper sensor stops sensing document in mm */ /* this is larger than needed -- accounts for second sensor head, which is a calibration item */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_XP300, DAC_WOLFSON_XP300, GPO_XP300, MOTOR_XP300, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION @@ -2761,48 +2797,48 @@ static Genesys_Model visioneer_xp300_model = { }; static Genesys_Model syscan_docketport_665_model = { - "syscan-docketport-665", /* Name */ - "Syscan/Ambir", /* Device vendor string */ - "DocketPORT 665", /* Device model name */ + "syscan-docketport-665", /* Name */ + "Syscan/Ambir", /* Device vendor string */ + "DocketPORT 665", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in mm (y) */ - SANE_FIX (108.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in mm (y) */ + SANE_FIX (108.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (17.5), /* Size of scan area after paper sensor stops + SANE_FIX (17.5), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_DP665, DAC_WOLFSON_XP300, GPO_DP665, MOTOR_DP665, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION @@ -2813,48 +2849,48 @@ static Genesys_Model syscan_docketport_665_model = { }; static Genesys_Model visioneer_roadwarrior_model = { - "visioneer-roadwarrior", /* Name */ - "Visioneer", /* Device vendor string */ - "Readwarrior", /* Device model name */ + "visioneer-roadwarrior", /* Name */ + "Visioneer", /* Device vendor string */ + "Readwarrior", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (16.0), /* Size of scan area after paper sensor stops + SANE_FIX (16.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_ROADWARRIOR, DAC_WOLFSON_XP300, GPO_DP665, MOTOR_ROADWARRIOR, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -2865,48 +2901,48 @@ static Genesys_Model visioneer_roadwarrior_model = { }; static Genesys_Model syscan_docketport_465_model = { - "syscan-docketport-465", /* Name */ - "Syscan", /* Device vendor string */ - "DocketPORT 465", /* Device model name */ + "syscan-docketport-465", /* Name */ + "Syscan", /* Device vendor string */ + "DocketPORT 465", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (16.0), /* Size of scan area after paper sensor stops + SANE_FIX (16.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_ROADWARRIOR, DAC_WOLFSON_XP300, GPO_DP665, MOTOR_ROADWARRIOR, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_NO_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -2917,48 +2953,48 @@ static Genesys_Model syscan_docketport_465_model = { }; static Genesys_Model visioneer_xp100_r3_model = { - "visioneer-xp100-revision3", /* Name */ - "Visioneer", /* Device vendor string */ - "XP100 Revision 3", /* Device model name */ + "visioneer-xp100-revision3", /* Name */ + "Visioneer", /* Device vendor string */ + "XP100 Revision 3", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (16.0), /* Size of scan area after paper sensor stops + SANE_FIX (16.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_ROADWARRIOR, DAC_WOLFSON_XP300, GPO_DP665, MOTOR_ROADWARRIOR, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -2969,48 +3005,48 @@ static Genesys_Model visioneer_xp100_r3_model = { }; static Genesys_Model pentax_dsmobile_600_model = { - "pentax-dsmobile-600", /* Name */ - "Pentax", /* Device vendor string */ - "DSmobile 600", /* Device model name */ + "pentax-dsmobile-600", /* Name */ + "Pentax", /* Device vendor string */ + "DSmobile 600", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (16.0), /* Size of scan area after paper sensor stops + SANE_FIX (16.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_DSMOBILE600, DAC_WOLFSON_DSM600, GPO_DP665, MOTOR_DSMOBILE_600, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -3021,48 +3057,48 @@ static Genesys_Model pentax_dsmobile_600_model = { }; static Genesys_Model syscan_docketport_467_model = { - "syscan-docketport-467", /* Name */ - "Syscan", /* Device vendor string */ - "DocketPORT 467", /* Device model name */ + "syscan-docketport-467", /* Name */ + "Syscan", /* Device vendor string */ + "DocketPORT 467", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (16.0), /* Size of scan area after paper sensor stops + SANE_FIX (16.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_DSMOBILE600, DAC_WOLFSON_DSM600, GPO_DP665, MOTOR_DSMOBILE_600, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -3073,49 +3109,49 @@ static Genesys_Model syscan_docketport_467_model = { }; static Genesys_Model syscan_docketport_685_model = { - "syscan-docketport-685", /* Name */ - "Syscan/Ambir", /* Device vendor string */ - "DocketPORT 685", /* Device model name */ + "syscan-docketport-685", /* Name */ + "Syscan/Ambir", /* Device vendor string */ + "DocketPORT 685", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (1.0), /* Start of scan area in mm (y) */ - SANE_FIX (212.0), /* Size of scan area in mm (x) */ - SANE_FIX (500), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (1.0), /* Start of scan area in mm (y) */ + SANE_FIX (212.0), /* Size of scan area in mm (x) */ + SANE_FIX (500), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (26.5), /* Size of scan area after paper sensor stops + SANE_FIX (26.5), /* Size of scan area after paper sensor stops sensing document in mm */ /* this is larger than needed -- accounts for second sensor head, which is a calibration item */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_DP685, DAC_WOLFSON_DSM600, GPO_DP685, MOTOR_XP300, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -3126,49 +3162,49 @@ static Genesys_Model syscan_docketport_685_model = { }; static Genesys_Model syscan_docketport_485_model = { - "syscan-docketport-485", /* Name */ - "Syscan/Ambir", /* Device vendor string */ - "DocketPORT 485", /* Device model name */ + "syscan-docketport-485", /* Name */ + "Syscan/Ambir", /* Device vendor string */ + "DocketPORT 485", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (1.0), /* Start of scan area in mm (y) */ - SANE_FIX (435.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (1.0), /* Start of scan area in mm (y) */ + SANE_FIX (435.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (26.5), /* Size of scan area after paper sensor stops + SANE_FIX (26.5), /* Size of scan area after paper sensor stops sensing document in mm */ /* this is larger than needed -- accounts for second sensor head, which is a calibration item */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_XP300, DAC_WOLFSON_XP300, GPO_XP300, MOTOR_XP300, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -3179,49 +3215,49 @@ static Genesys_Model syscan_docketport_485_model = { }; static Genesys_Model dct_docketport_487_model = { - "dct-docketport-487", /* Name */ - "DCT", /* Device vendor string */ - "DocketPORT 487", /* Device model name */ + "dct-docketport-487", /* Name */ + "DCT", /* Device vendor string */ + "DocketPORT 487", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.0), /* Start of scan area in mm (x) */ - SANE_FIX (1.0), /* Start of scan area in mm (y) */ - SANE_FIX (435.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in mm (x) */ + SANE_FIX (1.0), /* Start of scan area in mm (y) */ + SANE_FIX (435.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (26.5), /* Size of scan area after paper sensor stops + SANE_FIX (26.5), /* Size of scan area after paper sensor stops sensing document in mm */ /* this is larger than needed -- accounts for second sensor head, which is a calibration item */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_XP300, DAC_WOLFSON_XP300, GPO_XP300, MOTOR_XP300, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION @@ -3233,43 +3269,43 @@ static Genesys_Model dct_docketport_487_model = { }; static Genesys_Model visioneer_7100_model = { - "visioneer-7100-model", /* Name */ - "Visioneer", /* Device vendor string */ - "OneTouch 7100", /* Device model name */ + "visioneer-7100-model", /* Name */ + "Visioneer", /* Device vendor string */ + "OneTouch 7100", /* Device model name */ GENESYS_GL646, NULL, - {1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX ( 4.00), /* Start of scan area in mm (x) */ - SANE_FIX ( 0.80), /* 2.79 < Start of scan area in mm (y) */ - SANE_FIX (215.9), /* Size of scan area in mm (x) */ - SANE_FIX (296.4), /* Size of scan area in mm (y) */ + SANE_FIX ( 4.00), /* Start of scan area in mm (x) */ + SANE_FIX ( 0.80), /* 2.79 < Start of scan area in mm (y) */ + SANE_FIX (215.9), /* Size of scan area in mm (x) */ + SANE_FIX (296.4), /* Size of scan area in mm (y) */ - SANE_FIX (0.00), /* Start of white strip in mm (y) */ - SANE_FIX (0.00), /* Start of black mark in mm (x) */ + SANE_FIX (0.00), /* Start of white strip in mm (y) */ + SANE_FIX (0.00), /* Start of black mark in mm (x) */ - SANE_FIX (0.00), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.00), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (0.00), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (0.00), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.00), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.00), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (0.00), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (0.00), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.00), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.00), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ + 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ /* 48, 24, 0, */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_5345, DAC_WOLFSON_5345, GPO_5345, @@ -3288,43 +3324,43 @@ static Genesys_Model visioneer_7100_model = { }; static Genesys_Model xerox_2400_model = { - "xerox-2400-model", /* Name */ - "Xerox", /* Device vendor string */ - "OneTouch 2400", /* Device model name */ + "xerox-2400-model", /* Name */ + "Xerox", /* Device vendor string */ + "OneTouch 2400", /* Device model name */ GENESYS_GL646, NULL, - {1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible x-resolutions */ - {2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible x-resolutions */ + {2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX ( 4.00), /* Start of scan area in mm (x) */ - SANE_FIX ( 0.80), /* 2.79 < Start of scan area in mm (y) */ - SANE_FIX (215.9), /* Size of scan area in mm (x) */ - SANE_FIX (296.4), /* Size of scan area in mm (y) */ + SANE_FIX ( 4.00), /* Start of scan area in mm (x) */ + SANE_FIX ( 0.80), /* 2.79 < Start of scan area in mm (y) */ + SANE_FIX (215.9), /* Size of scan area in mm (x) */ + SANE_FIX (296.4), /* Size of scan area in mm (y) */ - SANE_FIX (0.00), /* Start of white strip in mm (y) */ - SANE_FIX (0.00), /* Start of black mark in mm (x) */ + SANE_FIX (0.00), /* Start of white strip in mm (y) */ + SANE_FIX (0.00), /* Start of black mark in mm (x) */ - SANE_FIX (0.00), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.00), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (0.00), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (0.00), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.00), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.00), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (0.00), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (0.00), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.00), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.00), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ + 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ /* 48, 24, 0, */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_5345, DAC_WOLFSON_5345, GPO_5345, @@ -3344,48 +3380,48 @@ static Genesys_Model xerox_2400_model = { static Genesys_Model xerox_travelscanner_model = { - "xerox-travelscanner", /* Name */ - "Xerox", /* Device vendor string */ - "Travelscanner 100", /* Device model name */ + "xerox-travelscanner", /* Name */ + "Xerox", /* Device vendor string */ + "Travelscanner 100", /* Device model name */ GENESYS_GL841, NULL, - {600, 300, 150, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {600, 300, 150, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (4.0), /* Start of scan area in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in mm (y) */ - SANE_FIX (220.0), /* Size of scan area in mm (x) */ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (4.0), /* Start of scan area in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in mm (y) */ + SANE_FIX (220.0), /* Size of scan area in mm (x) */ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (16.0), /* Size of scan area after paper sensor stops + SANE_FIX (16.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_TRUE, /* Is this a CIS scanner? */ - SANE_TRUE, /* Is this a sheetfed scanner? */ + SANE_TRUE, /* Is this a CIS scanner? */ + SANE_TRUE, /* Is this a sheetfed scanner? */ CCD_ROADWARRIOR, DAC_WOLFSON_XP300, GPO_DP665, MOTOR_ROADWARRIOR, - GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ + GENESYS_FLAG_LAZY_INIT /* Which flags are needed for this scanner? */ | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA @@ -3396,53 +3432,53 @@ static Genesys_Model xerox_travelscanner_model = { }; static Genesys_Model plustek_3600_model = { - "plustek-opticbook-3600", /* Name */ - "PLUSTEK", /* Device vendor string */ - "OpticBook 3600", /* Device model name */ + "plustek-opticbook-3600", /* Name */ + "PLUSTEK", /* Device vendor string */ + "OpticBook 3600", /* Device model name */ GENESYS_GL841, NULL, - {/*1200,*/ 600, 400, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ - {/*2400,*/ 1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {/*1200,*/ 600, 400, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */ + {/*2400,*/ 1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (0.42),/*SANE_FIX (0.42), Start of scan area in mm (x) */ - SANE_FIX (6.75),/*SANE_FIX (7.9), Start of scan area in mm (y) */ - SANE_FIX (216.0),/*SANE_FIX (216.0), Size of scan area in mm (x) */ - SANE_FIX (297.0),/*SANE_FIX (297.0), Size of scan area in mm (y) */ + SANE_FIX (0.42),/*SANE_FIX (0.42), Start of scan area in mm (x) */ + SANE_FIX (6.75),/*SANE_FIX (7.9), Start of scan area in mm (y) */ + SANE_FIX (216.0),/*SANE_FIX (216.0), Size of scan area in mm (x) */ + SANE_FIX (297.0),/*SANE_FIX (297.0), Size of scan area in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (0.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ + 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_PLUSTEK_3600, DAC_PLUSTEK_3600, GPO_PLUSTEK_3600, MOTOR_PLUSTEK_3600, - GENESYS_FLAG_UNTESTED /* not fully working yet */ + GENESYS_FLAG_UNTESTED /* not fully working yet */ | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION - | GENESYS_FLAG_LAZY_INIT - | GENESYS_FLAG_HALF_CCD_MODE,/* + | GENESYS_FLAG_LAZY_INIT + | GENESYS_FLAG_HALF_CCD_MODE,/* | GENESYS_FLAG_NO_CALIBRATION,*/ GENESYS_HAS_NO_BUTTONS, 7, @@ -3450,49 +3486,49 @@ static Genesys_Model plustek_3600_model = { }; static Genesys_Model hpn6310_model = { - "hewlett-packard-scanjet-N6310", /* Name */ - "Hewlett Packard", /* Device vendor string */ - "ScanJet N6310", /* Device model name */ + "hewlett-packard-scanjet-N6310", /* Name */ + "Hewlett Packard", /* Device vendor string */ + "ScanJet N6310", /* Device model name */ GENESYS_GL847, NULL, { 2400, 1200, 600, 400, 300, 200, 150, 100, 75, 0}, { 2400, 1200, 600, 400, 300, 200, 150, 100, 75, 0}, - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (6), /* Start of scan area in mm (x) */ - SANE_FIX (2), /* Start of scan area in mm (y) */ - SANE_FIX (216), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ - SANE_FIX (511), /* Size of scan area in mm (y) */ + SANE_FIX (6), /* Start of scan area in mm (x) */ + SANE_FIX (2), /* Start of scan area in mm (y) */ + SANE_FIX (216), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/ + SANE_FIX (511), /* Size of scan area in mm (y) */ - SANE_FIX (3.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (3.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0), /* Size of scan area after paper sensor stops + SANE_FIX (0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0), /* Amount of feeding needed to eject document + SANE_FIX (0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ + 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_HP_N6310, DAC_CANONLIDE200, /*Not defined yet for N6310 */ GPO_HP_N6310, MOTOR_CANONLIDE200, /*Not defined yet for N6310 */ - GENESYS_FLAG_UNTESTED /* not fully working yet */ + GENESYS_FLAG_UNTESTED /* not fully working yet */ | GENESYS_FLAG_LAZY_INIT | GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_DARK_CALIBRATION @@ -3509,43 +3545,43 @@ static Genesys_Model hpn6310_model = { static Genesys_Model plustek_3800_model = { - "plustek-opticbook-3800", /* Name */ - "PLUSTEK", /* Device vendor string */ - "OpticBook 3800", /* Device model name */ + "plustek-opticbook-3800", /* Name */ + "PLUSTEK", /* Device vendor string */ + "OpticBook 3800", /* Device model name */ GENESYS_GL845, NULL, - {1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (7.2), /* Start of scan area in mm (x) */ - SANE_FIX (14.7), /* Start of scan area in mm (y) */ - SANE_FIX (217.7), /* Size of scan area in mm (x) */ - SANE_FIX (300.0), /* Size of scan area in mm (y) */ + SANE_FIX (7.2), /* Start of scan area in mm (x) */ + SANE_FIX (14.7), /* Start of scan area in mm (y) */ + SANE_FIX (217.7), /* Size of scan area in mm (x) */ + SANE_FIX (300.0), /* Size of scan area in mm (y) */ - SANE_FIX (9.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (9.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ + 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_PLUSTEK3800, DAC_PLUSTEK3800, GPO_PLUSTEK3800, @@ -3554,50 +3590,50 @@ static Genesys_Model plustek_3800_model = { GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA, - GENESYS_HAS_NO_BUTTONS, /* TODO there are 4 buttons to support */ + GENESYS_HAS_NO_BUTTONS, /* TODO there are 4 buttons to support */ 100, 100 }; static Genesys_Model canon_formula101_model = { - "canon-image-formula-101", /* Name */ - "Canon", /* Device vendor string */ - "Image Formula 101", /* Device model name */ + "canon-image-formula-101", /* Name */ + "Canon", /* Device vendor string */ + "Image Formula 101", /* Device model name */ GENESYS_GL846, NULL, - {1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ - {1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ - {16, 8, 0}, /* possible depths in gray mode */ - {16, 8, 0}, /* possible depths in color mode */ + {1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */ + {1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */ + {16, 8, 0}, /* possible depths in gray mode */ + {16, 8, 0}, /* possible depths in color mode */ - SANE_FIX (7.2), /* Start of scan area in mm (x) */ - SANE_FIX (14.7), /* Start of scan area in mm (y) */ - SANE_FIX (217.7), /* Size of scan area in mm (x) */ - SANE_FIX (300.0), /* Size of scan area in mm (y) */ + SANE_FIX (7.2), /* Start of scan area in mm (x) */ + SANE_FIX (14.7), /* Start of scan area in mm (y) */ + SANE_FIX (217.7), /* Size of scan area in mm (x) */ + SANE_FIX (300.0), /* Size of scan area in mm (y) */ - SANE_FIX (9.0), /* Start of white strip in mm (y) */ - SANE_FIX (0.0), /* Start of black mark in mm (x) */ + SANE_FIX (9.0), /* Start of white strip in mm (y) */ + SANE_FIX (0.0), /* Start of black mark in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ - SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (x) */ + SANE_FIX (0.0), /* Size of scan area in TA mode in mm (y) */ - SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ + SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */ - SANE_FIX (0.0), /* Size of scan area after paper sensor stops + SANE_FIX (0.0), /* Size of scan area after paper sensor stops sensing document in mm */ - SANE_FIX (0.0), /* Amount of feeding needed to eject document + SANE_FIX (0.0), /* Amount of feeding needed to eject document after finishing scanning in mm */ - 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ + 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ - COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ + COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ - SANE_FALSE, /* Is this a CIS scanner? */ - SANE_FALSE, /* Is this a sheetfed scanner? */ + SANE_FALSE, /* Is this a CIS scanner? */ + SANE_FALSE, /* Is this a sheetfed scanner? */ CCD_IMG101, DAC_IMG101, GPO_IMG101, diff --git a/backend/genesys_gl124.c b/backend/genesys_gl124.c index eaac873..a98d3d4 100644 --- a/backend/genesys_gl124.c +++ b/backend/genesys_gl124.c @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2016 Stéphane Voltz This file is part of the SANE package. @@ -112,7 +112,7 @@ gl124_bulk_read_data (Genesys_Device * dev, uint8_t addr, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "%s failed while writing command: %s\n", - __FUNCTION__, sane_strstatus (status)); + __func__, sane_strstatus (status)); return status; } @@ -154,7 +154,7 @@ gl124_bulk_read_data (Genesys_Device * dev, uint8_t addr, } } - DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __FUNCTION__, + DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, (u_long) size, (u_long) (target - size)); target -= size; @@ -294,7 +294,7 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi, int half_ccd /* default fallback */ if(idx<0) { - DBG (DBG_warn,"%s: using default sensor profile\n",__FUNCTION__); + DBG (DBG_warn,"%s: using default sensor profile\n",__func__); idx=0; } @@ -356,10 +356,18 @@ gl124_init_registers (Genesys_Device * dev) SETREG (0x01,0xa2); /* + REG01_SHDAREA */ SETREG (0x02,0x90); SETREG (0x03,0x50); - SETREG (0x03,0x50 & ~REG03_AVEENB); SETREG (0x04,0x03); SETREG (0x05,0x00); - SETREG (0x06,0x50 | REG06_GAIN4); + if(dev->model->ccd_type==CIS_CANONLIDE120) + { + SETREG (0x06,0x50); + SETREG (0x07,0x00); + } + else + { + SETREG (0x03,0x50 & ~REG03_AVEENB); + SETREG (0x06,0x50 | REG06_GAIN4); + } SETREG (0x09,0x00); SETREG (0x0a,0xc0); SETREG (0x0b,0x2a); @@ -381,7 +389,14 @@ gl124_init_registers (Genesys_Device * dev) SETREG (0x1f,0x00); SETREG (0x20,0x15); SETREG (0x21,0x00); - SETREG (0x22,0x02); + if(dev->model->ccd_type!=CIS_CANONLIDE120) + { + SETREG (0x22,0x02); + } + else + { + SETREG (0x22,0x14); + } SETREG (0x23,0x00); SETREG (0x24,0x00); SETREG (0x25,0x00); @@ -434,11 +449,19 @@ gl124_init_registers (Genesys_Device * dev) SETREG (0x6a,0x00); SETREG (0x6b,0x00); SETREG (0x6c,0x00); - SETREG (0x6d,0xd0); SETREG (0x6e,0x00); SETREG (0x6f,0x00); - SETREG (0x70,0x06); - SETREG (0x71,0x08); + if(dev->model->ccd_type!=CIS_CANONLIDE120) + { + SETREG (0x6d,0xd0); + SETREG (0x71,0x08); + } + else + { + SETREG (0x6d,0x00); + SETREG (0x71,0x1f); + } + SETREG (0x70,0x00); SETREG (0x72,0x08); SETREG (0x73,0x0a); @@ -456,8 +479,16 @@ gl124_init_registers (Genesys_Device * dev) SETREG (0x7d,0x00); SETREG (0x7e,0x08); SETREG (0x7f,0x58); - SETREG (0x80,0x00); - SETREG (0x81,0x14); + if(dev->model->ccd_type!=CIS_CANONLIDE120) + { + SETREG (0x80,0x00); + SETREG (0x81,0x14); + } + else + { + SETREG (0x80,0x00); + SETREG (0x81,0x10); + } /* STRPIXEL */ SETREG (0x82,0x00); @@ -536,6 +567,15 @@ gl124_init_registers (Genesys_Device * dev) SETREG (0xcd,0x00); SETREG (0xce,0x00); */ + if(dev->model->ccd_type==CIS_CANONLIDE120) + { + SETREG (0xc5,0x20); + SETREG (0xc6,0xeb); + SETREG (0xc7,0x20); + SETREG (0xc8,0xeb); + SETREG (0xc9,0x20); + SETREG (0xca,0xeb); + } /* memory layout SETREG (0xd0,0x0a); @@ -624,13 +664,13 @@ gl124_send_slope_table (Genesys_Device * dev, int table_nr, int i; char msg[10000]; - DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __FUNCTION__, + DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __func__, table_nr, steps); /* sanity check */ if(table_nr<0 || table_nr>4) { - DBG (DBG_error, "%s: invalid table number %d!\n", __FUNCTION__, table_nr); + DBG (DBG_error, "%s: invalid table number %d!\n", __func__, table_nr); return SANE_STATUS_INVAL; } @@ -648,7 +688,7 @@ gl124_send_slope_table (Genesys_Device * dev, int table_nr, { sprintf (msg+strlen(msg), ",%d", slope_table[i]); } - DBG (DBG_io, "%s: %s\n", __FUNCTION__, msg); + DBG (DBG_io, "%s: %s\n", __func__, msg); } /* slope table addresses are fixed */ @@ -658,7 +698,7 @@ gl124_send_slope_table (Genesys_Device * dev, int table_nr, { DBG (DBG_error, "%s: write to AHB failed writing slope table %d (%s)\n", - __FUNCTION__, table_nr, sane_strstatus (status)); + __func__, table_nr, sane_strstatus (status)); } free (table); @@ -666,8 +706,11 @@ gl124_send_slope_table (Genesys_Device * dev, int table_nr, return status; } -/** - * Set register values of 'special' type frontend +/** @brief * Set register values of 'special' ti type frontend + * Registers value are taken from the frontend register data + * set. + * @param dev device owning the AFE + * @param set flag AFE_INIT to specify the AFE must be reset before writing data * */ static SANE_Status gl124_set_ti_fe (Genesys_Device * dev, uint8_t set) @@ -679,8 +722,7 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set) DBGSTART; if (set == AFE_INIT) { - DBG (DBG_proc, "%s: setting DAC %u\n", __FUNCTION__, - dev->model->dac_type); + DBG (DBG_proc, "%s: setting DAC %u\n", __func__, dev->model->dac_type); /* sets to default values */ sanei_genesys_init_fe (dev); @@ -690,7 +732,7 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, 0x80); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to write reg0: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus (status)); return status; } @@ -703,7 +745,7 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to write reg %d: %s\n", __FUNCTION__, i, + "%s: failed to write reg %d: %s\n", __func__, i, sane_strstatus (status)); return status; } @@ -712,12 +754,12 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x04, 0x00); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to write reg4: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to write reg4: %s\n", __func__, sane_strstatus (status)); return status; } - /* these are not really sign */ + /* these are not really sign for this AFE */ for (i = 0; i < 3; i++) { val = dev->frontend.sign[i]; @@ -725,17 +767,24 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to write reg %d: %s\n", __FUNCTION__, i+5, + "%s: failed to write reg %d: %s\n", __func__, i+5, sane_strstatus (status)); return status; } } /* close writing to DAC */ - status = sanei_genesys_fe_write_data (dev, 0x00, 0x11); + if(dev->model->dac_type == DAC_CANONLIDE120) + { + status = sanei_genesys_fe_write_data (dev, 0x00, 0x01); + } + else + { + status = sanei_genesys_fe_write_data (dev, 0x00, 0x11); + } if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to write reg0: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus (status)); return status; } @@ -781,7 +830,7 @@ gl124_set_fe (Genesys_Device * dev, uint8_t set) case 1: case 2: default: - DBG (DBG_error, "%s: unsupported analog FE 0x%02x\n",__FUNCTION__,val); + DBG (DBG_error, "%s: unsupported analog FE 0x%02x\n",__func__,val); status=SANE_STATUS_INVAL; break; } @@ -852,10 +901,17 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, } else { - min_speed = 900; - if(dev->model->ccd_type==MOTOR_CANONLIDE110) + switch(dev->model->motor_type) { - min_speed = 300; + case MOTOR_CANONLIDE110: + min_speed = 600; + break; + case MOTOR_CANONLIDE120: + min_speed = 900; + break; + default: + min_speed = 900; + break; } } @@ -864,6 +920,12 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, { yres=min_speed; linesel=yres/scan_yres-1; + /* limit case, we need a linesel > 0 */ + if(linesel==0) + { + linesel=1; + yres=scan_yres*2; + } } else { @@ -871,11 +933,11 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, linesel=0; } - DBG (DBG_io2, "%s: linesel=%d\n", __FUNCTION__, linesel); + DBG (DBG_io2, "%s: final yres=%f, linesel=%d\n", __func__, yres, linesel); lincnt=scan_lines*(linesel+1); sanei_genesys_set_triple(reg,REG_LINCNT,lincnt); - DBG (DBG_io, "%s: lincnt=%d\n", __FUNCTION__, lincnt); + DBG (DBG_io, "%s: lincnt=%d\n", __func__, lincnt); /* compute register 02 value */ r = sanei_genesys_get_address (reg, REG02); @@ -954,7 +1016,7 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, { dist += fast_steps*2; } - DBG (DBG_io2, "%s: acceleration distance=%d\n", __FUNCTION__, dist); + DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* get sure we don't use insane value */ if(distvalue = dev->sensor.regs_0x10_0x1d[i]; + { + r->value = dev->sensor.regs_0x10_0x1d[i]; + } } + /* skip writing 5d,5e which is AFE address because + * they are not deifned in register set */ for (i = 0; i < 11; i++) { r = sanei_genesys_get_address (regs, 0x52 + i); if (r) - r->value = dev->sensor.regs_0x52_0x5e[i]; + { + r->value = dev->sensor.regs_0x52_0x5e[i]; + } } /* set EXPDUMMY and CKxMAP */ @@ -1054,6 +1127,23 @@ gl124_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi, r->value = sensor->reg98; } + if(sensor->reg16!=0) + { + r = sanei_genesys_get_address (regs, 0x16); + if (r) + { + r->value = sensor->reg16; + } + } + if(sensor->reg70!=0) + { + r = sanei_genesys_get_address (regs, 0x70); + if (r) + { + r->value = sensor->reg70; + } + } + sanei_genesys_set_triple(regs,REG_SEGCNT,sensor->segcnt); sanei_genesys_set_double(regs,REG_TG0CNT,sensor->tg0cnt); sanei_genesys_set_double(regs,REG_EXPDMY,sensor->expdummy); @@ -1131,19 +1221,19 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, DBG (DBG_proc, "%s : exposure_time=%d, " "used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " - "half_ccd=%d, flags=%x\n", __FUNCTION__, exposure_time, + "half_ccd=%d, flags=%x\n", __func__, exposure_time, used_res, start, pixels, channels, depth, half_ccd, flags); /* resolution is divided according to CKSEL */ r = sanei_genesys_get_address (reg, REG18); cksel= (r->value & REG18_CKSEL)+1; - DBG (DBG_io2, "%s: cksel=%d\n", __FUNCTION__, cksel); + DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel); /* to manage high resolution device while keeping good * low resolution scanning speed, we make hardware dpi vary */ dpihw=sanei_genesys_compute_dpihw(dev, used_res * cksel); factor=dev->sensor.optical_res/dpihw; - DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __FUNCTION__, dpihw, factor); + DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); /* sensor parameters */ gl124_setup_sensor (dev, reg, dpihw, half_ccd); @@ -1163,7 +1253,7 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, status = gl124_set_fe (dev, AFE_SET); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set frontend: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1183,7 +1273,16 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, r->value &= ~REG01_SCAN; r = sanei_genesys_get_address (reg, REG03); - r->value &= ~REG03_AVEENB; + if((dev->model->ccd_type!=CIS_CANONLIDE120)&&(used_res>=600)) + { + r->value &= ~REG03_AVEENB; + DBG (DBG_io, "%s: disabling AVEENB\n", __func__); + } + else + { + r->value |= ~REG03_AVEENB; + DBG (DBG_io, "%s: enabling AVEENB\n", __func__); + } if (flags & OPTICAL_FLAG_DISABLE_LAMP) r->value &= ~REG03_LAMPPWR; @@ -1217,13 +1316,13 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, switch (color_filter) { case 0: - r->value |= 0x10; /* red filter */ + r->value |= 0x10; /* red filter */ break; case 2: - r->value |= 0x30; /* blue filter */ + r->value |= 0x30; /* blue filter */ break; default: - r->value |= 0x20; /* green filter */ + r->value |= 0x20; /* green filter */ break; } } @@ -1258,12 +1357,12 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, if(half_ccd) { sanei_genesys_set_double(reg,REG_DPISET,dpiset*2); - DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset*2); + DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset*2); } else { sanei_genesys_set_double(reg,REG_DPISET,dpiset); - DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset); + DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); } r = sanei_genesys_get_address (reg, REG06); @@ -1310,14 +1409,14 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, segnb = r->value & 0x0f; sanei_genesys_set_triple(reg,REG_STRPIXEL,startx/segnb); - DBG (DBG_io2, "%s: strpixel used=%d\n", __FUNCTION__, startx/segnb); + DBG (DBG_io2, "%s: strpixel used=%d\n", __func__, startx/segnb); sanei_genesys_get_triple(reg,REG_SEGCNT,&segcnt); if(endx/segnb==segcnt) { endx=0; } sanei_genesys_set_triple(reg,REG_ENDPIXEL,endx/segnb); - DBG (DBG_io2, "%s: endpixel used=%d\n", __FUNCTION__, endx/segnb); + DBG (DBG_io2, "%s: endpixel used=%d\n", __func__, endx/segnb); /* words(16bit) before gamma, conversion to 8 bit or lineart */ words_per_line = (used_pixels * dpiset) / dpihw; @@ -1340,13 +1439,13 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, dev->line_count = 0; dev->line_interp = 0; - DBG (DBG_io2, "%s: used_pixels =%d\n", __FUNCTION__, used_pixels); - DBG (DBG_io2, "%s: pixels =%d\n", __FUNCTION__, pixels); - DBG (DBG_io2, "%s: depth =%d\n", __FUNCTION__, depth); - DBG (DBG_io2, "%s: dev->bpl =%lu\n", __FUNCTION__, (unsigned long)dev->bpl); - DBG (DBG_io2, "%s: dev->len =%lu\n", __FUNCTION__, (unsigned long)dev->len); - DBG (DBG_io2, "%s: dev->dist =%lu\n", __FUNCTION__, (unsigned long)dev->dist); - DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __FUNCTION__, (unsigned long)dev->line_interp); + DBG (DBG_io2, "%s: used_pixels =%d\n", __func__, used_pixels); + DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); + DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); + DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl); + DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); + DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); + DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __func__, (unsigned long)dev->line_interp); words_per_line *= channels; dev->wpl = words_per_line; @@ -1360,10 +1459,10 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, /* MAXWD is expressed in 2 words unit */ sanei_genesys_set_triple(reg,REG_MAXWD,(words_per_line)); - DBG (DBG_io2, "%s: words_per_line used=%d\n", __FUNCTION__, words_per_line); + DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); sanei_genesys_set_triple(reg,REG_LPERIOD,exposure_time); - DBG (DBG_io2, "%s: exposure_time used=%d\n", __FUNCTION__, exposure_time); + DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); sanei_genesys_set_double(reg,REG_DUMMY,dev->sensor.dummy_pixel); @@ -1371,7 +1470,7 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, return SANE_STATUS_GOOD; } -/* set up registers for an actual scan +/** set up registers for an actual scan * * this function sets up the scanner to scan in normal or single line mode */ @@ -1379,10 +1478,10 @@ GENESYS_STATIC SANE_Status gl124_init_scan_regs (Genesys_Device * dev, Genesys_Register_Set * reg, - float xres, /*dpi */ - float yres, /*dpi */ - float startx, /*optical_res, from dummy_pixel+1 */ - float starty, /*base_ydpi, from home! */ + float xres, /*dpi */ + float yres, /*dpi */ + float startx, /*optical_res, from dummy_pixel+1 */ + float starty, /*base_ydpi, from home! */ float pixels, float lines, unsigned int depth, @@ -1407,7 +1506,7 @@ gl124_init_scan_regs (Genesys_Device * dev, int max_shift; size_t requested_buffer_size, read_buffer_size; - SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */ + SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */ int optical_res; SANE_Status status; @@ -1427,7 +1526,7 @@ gl124_init_scan_regs (Genesys_Device * dev, optical_res = dev->sensor.optical_res; if (half_ccd) optical_res /= 2; - DBG (DBG_info, "%s: optical_res=%d\n", __FUNCTION__, optical_res); + DBG (DBG_info, "%s: optical_res=%d\n", __func__, optical_res); /* stagger */ if ((!half_ccd) && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) @@ -1463,7 +1562,7 @@ gl124_init_scan_regs (Genesys_Device * dev, /* compute correct pixels number */ used_pixels = (pixels * optical_res) / xres; - DBG (DBG_info, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); + DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* round up pixels number if needed */ if (used_pixels * xres < pixels * optical_res) @@ -1607,7 +1706,7 @@ gl124_init_scan_regs (Genesys_Device * dev, dev->current_setup.pixels = (used_pixels * used_res) / optical_res; - DBG (DBG_info, "%s: current_setup.pixels=%d\n", __FUNCTION__, dev->current_setup.pixels); + DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.depth = depth; dev->current_setup.channels = channels; @@ -1642,9 +1741,9 @@ gl124_calculate_current_setup (Genesys_Device * dev) int depth; int start; - float xres; /*dpi */ - float yres; /*dpi */ - float startx; /*optical_res, from dummy_pixel+1 */ + float xres; /*dpi */ + float yres; /*dpi */ + float startx; /*optical_res, from dummy_pixel+1 */ float pixels; float lines; @@ -1672,7 +1771,7 @@ gl124_calculate_current_setup (Genesys_Device * dev) dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ - if (dev->settings.scan_mode == 4) /* single pass color */ + if (dev->settings.scan_mode == 4) /* single pass color */ channels = 3; else channels = 1; @@ -1720,11 +1819,11 @@ gl124_calculate_current_setup (Genesys_Device * dev) /* compute correct pixels number */ used_pixels = (pixels * optical_res) / xres; - DBG (DBG_info, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); + DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* exposure */ exposure_time = gl124_compute_exposure (dev, xres, half_ccd); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time); + DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /* max_shift */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); @@ -1740,13 +1839,13 @@ gl124_calculate_current_setup (Genesys_Device * dev) stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "%s: stagger=%d lines\n", __FUNCTION__, stagger); + DBG (DBG_info, "%s: stagger=%d lines\n", __func__, stagger); /* lincnt */ lincnt = lines + max_shift + stagger; dev->current_setup.pixels = (used_pixels * used_res) / optical_res; - DBG (DBG_info, "%s: current_setup.pixels=%d\n", __FUNCTION__, dev->current_setup.pixels); + DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.depth = depth; dev->current_setup.channels = channels; @@ -1878,7 +1977,7 @@ gl124_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read reg100: %s\n", __FUNCTION__, + "%s: failed to read reg100: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -1887,7 +1986,7 @@ gl124_stop_action (Genesys_Device * dev) /* only stop action if needed */ if (!(val40 & REG100_DATAENB) && !(val40 & REG100_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __FUNCTION__); + DBG (DBG_info, "%s: already stopped\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -1900,7 +1999,7 @@ gl124_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to write register 01: %s\n", __FUNCTION__, + "%s: failed to write register 01: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1918,7 +2017,7 @@ gl124_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -1941,6 +2040,13 @@ gl124_stop_action (Genesys_Device * dev) } +/** @brief setup GPIOs for scan + * Setup GPIO values to drive motor (or light) needed for the + * target resolution + * @param *dev device to set up + * @param resolution dpi of the target scan + * @return SANE_STATUS_GOOD unless REG32 cannot be read + */ static SANE_Status gl124_setup_scan_gpio(Genesys_Device *dev, int resolution) { @@ -1949,17 +2055,43 @@ uint8_t val; DBGSTART; RIE (sanei_genesys_read_register (dev, REG32, &val)); - if(resolution>=dev->motor.base_ydpi/2) - { - val &= 0xf7; - } - else if(resolution>=dev->motor.base_ydpi/4) + + /* LiDE 110, 210 and 220 cases */ + if(dev->model->gpo_type != GPO_CANONLIDE120) { - val &= 0xef; + if(resolution>=dev->motor.base_ydpi/2) + { + val &= 0xf7; + } + else if(resolution>=dev->motor.base_ydpi/4) + { + val &= 0xef; + } + else + { + val |= 0x10; + } } + /* 120 : <=300 => 0x53 */ else - { - val |= 0x10; + { /* base_ydpi is 4800 */ + if(resolution<=300) + { + val &= 0xf7; + } + else if(resolution<=600) + { + val |= 0x08; + } + else if(resolution<=1200) + { + val &= 0xef; + val |= 0x08; + } + else + { + val &= 0xf7; + } } val |= 0x02; RIE (sanei_genesys_write_register (dev, REG32, val)); @@ -2026,7 +2158,7 @@ gl124_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, { status = SANE_STATUS_GOOD; } - else /* flat bed scanners */ + else /* flat bed scanners */ { status = gl124_stop_action (dev); if (status != SANE_STATUS_GOOD) @@ -2043,12 +2175,51 @@ gl124_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, } -/** @brief Moves the slider to the home (top) position slowly - * */ -#ifndef UNIT_TESTING -static -#endif - SANE_Status +/** rewind scan + * Move back by the same amount of distance than previous scan. + * @param dev device to rewind + * @returns SANE_STATUS_GOOD on success + */ +GENESYS_STATIC +SANE_Status gl124_rewind(Genesys_Device * dev) +{ + SANE_Status status; + uint8_t byte; + + DBGSTART; + + /* set motor reverse */ + RIE (sanei_genesys_read_register (dev, 0x02, &byte)); + byte |= 0x04; + RIE (sanei_genesys_write_register(dev, 0x02, byte)); + + /* and start scan, then wait completion */ + RIE (gl124_begin_scan (dev, dev->reg, SANE_TRUE)); + do + { + usleep(100*1000); + RIE (sanei_genesys_read_register (dev, REG100, &byte)); + } + while(byte & REG100_MOTMFLG); + RIE (gl124_end_scan (dev, dev->reg, SANE_TRUE)); + + /* restore direction */ + RIE (sanei_genesys_read_register (dev, 0x02, &byte)); + byte &= 0xfb; + RIE (sanei_genesys_write_register(dev, 0x02, byte)); + DBGCOMPLETED; + return SANE_STATUS_GOOD; +} + + +/** Park head + * Moves the slider to the home (top) position slowly + * @param dev device to park + * @param wait_until_home true to make the function waiting for head + * to be home before returning, if fals returne immediately + * @returns SANE_STATUS_GOO on success */ +GENESYS_STATIC +SANE_Status gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) { Genesys_Register_Set local_reg[GENESYS_GL124_MAX_REGS]; @@ -2083,7 +2254,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) { sanei_genesys_print_status (val); } - usleep (100000); /* sleep 100 ms */ + usleep (100000); /* sleep 100 ms */ /* second is reliable */ status = sanei_genesys_get_status (dev, &val); @@ -2102,7 +2273,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* is sensor at home? */ if (val & HOMESNR) { - DBG (DBG_info, "%s: already at home, completed\n", __FUNCTION__); + DBG (DBG_info, "%s: already at home, completed\n", __func__); dev->scanhead_position_in_steps = 0; DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -2114,7 +2285,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl124_feed (dev, 20, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to do initial feed: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to do initial feed: %s\n", __func__, sane_strstatus (status)); return status; } } @@ -2176,7 +2347,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) if (wait_until_home) { - while (loop < 300) /* do not wait longer then 30 seconds */ + while (loop < 300) /* do not wait longer then 30 seconds */ { status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) @@ -2187,14 +2358,14 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) return status; } - if (val & HOMESNR) /* home sensor */ + if (val & HOMESNR) /* home sensor */ { DBG (DBG_info, "gl124_slow_back_home: reached home position\n"); DBGCOMPLETED; dev->scanhead_position_in_steps = 0; return SANE_STATUS_GOOD; } - usleep (100000); /* sleep 100 ms */ + usleep (100000); /* sleep 100 ms */ ++loop; } @@ -2228,7 +2399,7 @@ gl124_feed (Genesys_Device * dev, unsigned int steps, int reverse) uint8_t val; DBGSTART; - DBG (DBG_io, "%s: steps=%d\n", __FUNCTION__, steps); + DBG (DBG_io, "%s: steps=%d\n", __func__, steps); /* prepare local registers */ memcpy (local_reg, dev->reg, GENESYS_GL124_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2254,7 +2425,7 @@ gl124_feed (Genesys_Device * dev, unsigned int steps, int reverse) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set up registers: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; } @@ -2273,7 +2444,7 @@ gl124_feed (Genesys_Device * dev, unsigned int steps, int reverse) r->value &= ~REG01_SCAN; /* set up for reverse if needed */ - if(reverse) + if(reverse) { r = sanei_genesys_get_address (local_reg, REG02); r->value |= REG02_MTRREV; @@ -2285,7 +2456,7 @@ gl124_feed (Genesys_Device * dev, unsigned int steps, int reverse) status = gl124_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); gl124_stop_action (dev); /* restore original registers */ @@ -2336,14 +2507,14 @@ gl124_search_start_position (Genesys_Device * dev) dpi, dpi, 0, - 0, /*we should give a small offset here~60 steps */ + 0, /*we should give a small offset here~60 steps */ 600, dev->model->search_lines, 8, 1, dev->settings.scan_method, SCAN_MODE_GRAY, - 1, /*green */ + 1, /*green */ SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_IGNORE_LINE_DISTANCE | @@ -2351,7 +2522,7 @@ gl124_search_start_position (Genesys_Device * dev) if (status!=SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to init scan registers: %s\n", __FUNCTION__, + "%s: failed to init scan registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2448,10 +2619,10 @@ gl124_init_regs_for_coarse_calibration (Genesys_Device * dev) uint8_t cksel; DBGSTART; - cksel = (dev->calib_reg[reg_0x18].value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */ + cksel = (dev->calib_reg[reg_0x18].value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */ /* set line size */ - if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */ + if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */ channels = 3; else channels = 1; @@ -2540,7 +2711,7 @@ gl124_init_regs_for_shading (Genesys_Device * dev) move = SANE_UNFIX (dev->model->y_offset_calib); move = (move * (dev->motor.base_ydpi/4)) / MM_PER_INCH; } - DBG (DBG_io, "%s: move=%d steps\n", __FUNCTION__, move); + DBG (DBG_io, "%s: move=%d steps\n", __func__, move); status = gl124_init_scan_regs (dev, dev->calib_reg, @@ -2563,7 +2734,7 @@ gl124_init_regs_for_shading (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2574,7 +2745,7 @@ gl124_init_regs_for_shading (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to bulk write registers: %s\n", __FUNCTION__, + "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2613,14 +2784,14 @@ gl124_init_regs_for_scan (Genesys_Device * dev) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to read status: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; } status = sanei_genesys_read_register (dev, REG100, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to read reg100: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to read reg100: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; } @@ -2632,14 +2803,14 @@ gl124_init_regs_for_scan (Genesys_Device * dev) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to read status: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; } status = sanei_genesys_read_register (dev, REG100, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to read reg100: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to read reg100: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; } @@ -2666,14 +2837,14 @@ gl124_init_regs_for_scan (Genesys_Device * dev) move = SANE_UNFIX (dev->model->y_offset); move += dev->settings.tl_y; move = (move * move_dpi) / MM_PER_INCH; - DBG (DBG_info, "%s: move=%f steps\n", __FUNCTION__, move); + DBG (DBG_info, "%s: move=%f steps\n", __func__, move); if(channels*dev->settings.yres>=600 && move>700) { status = gl124_feed (dev, move-500, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to move to scan area\n",__FUNCTION__); + DBG (DBG_error, "%s: failed to move to scan area\n",__func__); return status; } move=500; @@ -2737,7 +2908,7 @@ gl124_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t val,*buffer,*ptr,*src; DBGSTART; - DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__FUNCTION__,size); + DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__func__,size); /* logical size of a color as seen by generic code of the frontend */ length = (uint32_t) (size / 3); @@ -2748,13 +2919,13 @@ gl124_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) { endpixel=segcnt; } - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, SEGCNT=%d\n",__FUNCTION__,strpixel,endpixel,endpixel-strpixel,segcnt); + DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, SEGCNT=%d\n",__func__,strpixel,endpixel,endpixel-strpixel,segcnt); /* compute deletion factor */ sanei_genesys_get_double(dev->reg,REG_DPISET,&dpiset); dpihw=sanei_genesys_compute_dpihw(dev,dpiset); factor=dpihw/dpiset; - DBG( DBG_io2, "%s: factor=%d\n",__FUNCTION__,factor); + DBG( DBG_io2, "%s: factor=%d\n",__func__,factor); /* binary data logging */ if(DBG_LEVEL>=DBG_data) @@ -2774,7 +2945,7 @@ gl124_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) segcnt*=2*2; pixels=endpixel-strpixel; - DBG( DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n",__FUNCTION__,length, length/4); + DBG( DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n",__func__,length, length/4); buffer=(uint8_t *)malloc(pixels*dev->segnb); memset(buffer,0,pixels*dev->segnb); @@ -2892,7 +3063,7 @@ move_to_calibration_area (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2904,7 +3075,7 @@ move_to_calibration_area (Genesys_Device * dev) /* write registers and scan data */ RIEF (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS), line); - DBG (DBG_info, "%s: starting line reading\n", __FUNCTION__); + DBG (DBG_info, "%s: starting line reading\n", __func__); RIEF (gl124_begin_scan (dev, dev->calib_reg, SANE_TRUE), line); RIEF (sanei_genesys_read_data_from_scanner (dev, line, size), line); @@ -2992,11 +3163,11 @@ gl124_led_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } - total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */ + total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */ line = malloc (total_size); if (!line) return SANE_STATUS_NO_MEM; @@ -3190,7 +3361,7 @@ gl124_offset_calibration (Genesys_Device * dev) gl124_set_motor_power (dev->calib_reg, SANE_FALSE); /* allocate memory for scans */ - total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */ + total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */ first_line = malloc (total_size); if (!first_line) @@ -3503,7 +3674,7 @@ gl124_init_regs_for_warmup (Genesys_Device * dev, num_pixels = dev->current_setup.pixels; - *total_size = num_pixels * 3 * 1; /* colors * bytes_per_color * scan lines */ + *total_size = num_pixels * 3 * 1; /* colors * bytes_per_color * scan lines */ gl124_set_motor_power (reg, SANE_FALSE); RIE (dev->model->cmd_set->bulk_write_register (dev, reg, GENESYS_GL124_MAX_REGS)); @@ -3512,12 +3683,10 @@ gl124_init_regs_for_warmup (Genesys_Device * dev, return SANE_STATUS_GOOD; } -/** +/** @brief default GPIO values * set up GPIO/GPOE for idle state -WRITE GPIO[17-21]= GPIO19 -WRITE GPOE[17-21]= GPOE21 GPOE20 GPOE19 GPOE18 -genesys_write_register(0xa8,0x3e) -GPIO(0xa8)=0x3e + * @param dev device to set up + * @return SANE_STATUS_GOOD unless a GPIO register cannot be written */ static SANE_Status gl124_init_gpio (Genesys_Device * dev) @@ -3528,13 +3697,16 @@ gl124_init_gpio (Genesys_Device * dev) DBGSTART; /* per model GPIO layout */ - if ((strcmp (dev->model->name, "canon-lide-110") == 0) - ||(strcmp (dev->model->name, "canon-lide-120") == 0)) + if (strcmp (dev->model->name, "canon-lide-110") == 0) { idx = 0; } + else if (strcmp (dev->model->name, "canon-lide-110") == 0) + { + idx = 2; + } else - { /* canon LiDE 210 and 220 case */ + { /* canon LiDE 210 and 220 case */ idx = 1; } @@ -3568,7 +3740,7 @@ gl124_init_memory_layout (Genesys_Device * dev) idx = 0; } else - { /* canon LiDE 210 and 220 case */ + { /* canon LiDE 210 and 220 case */ idx = 1; } @@ -3587,18 +3759,18 @@ gl124_init_memory_layout (Genesys_Device * dev) /* size for each buffer is 0x16d*1k word */ sanei_genesys_write_register (dev, 0xe0, layouts[idx].re0); sanei_genesys_write_register (dev, 0xe1, layouts[idx].re1); -/* R-Channel ODD image buffer end-address 0x0291->0x148800 => size=0xB6800*/ + /* R-Channel ODD image buffer end-address 0x0291->0x148800 => size=0xB6800*/ sanei_genesys_write_register (dev, 0xe2, layouts[idx].re2); sanei_genesys_write_register (dev, 0xe3, layouts[idx].re3); /* R-Channel EVEN image buffer 0x0292 */ sanei_genesys_write_register (dev, 0xe4, layouts[idx].re4); sanei_genesys_write_register (dev, 0xe5, layouts[idx].re5); -/* R-Channel EVEN image buffer end-address 0x03ff*/ + /* R-Channel EVEN image buffer end-address 0x03ff*/ sanei_genesys_write_register (dev, 0xe6, layouts[idx].re6); sanei_genesys_write_register (dev, 0xe7, layouts[idx].re7); -/* same for green, since CIS, same addresses */ + /* same for green, since CIS, same addresses */ sanei_genesys_write_register (dev, 0xe8, layouts[idx].re0); sanei_genesys_write_register (dev, 0xe9, layouts[idx].re1); sanei_genesys_write_register (dev, 0xea, layouts[idx].re2); @@ -3725,7 +3897,8 @@ gl124_update_hardware_sensors (Genesys_Scanner * s) * add another per scanner button profile struct to avoid growing * hard-coded button mapping here. */ - if(s->dev->model->gpo_type == GPO_CANONLIDE110) + if((s->dev->model->gpo_type == GPO_CANONLIDE110) + ||(s->dev->model->gpo_type == GPO_CANONLIDE120)) { if (s->val[OPT_SCAN_SW].b == s->last_val[OPT_SCAN_SW].b) s->val[OPT_SCAN_SW].b = (val & 0x01) == 0; @@ -3755,7 +3928,7 @@ gl124_update_hardware_sensors (Genesys_Scanner * s) /** the gl124 command set */ static Genesys_Command_Set gl124_cmd_set = { - "gl124-generic", /* the name of this set */ + "gl124-generic", /* the name of this set */ gl124_init, gl124_init_regs_for_warmup, @@ -3792,6 +3965,7 @@ static Genesys_Command_Set gl124_cmd_set = { gl124_led_calibration, gl124_slow_back_home, + gl124_rewind, sanei_genesys_bulk_write_register, NULL, diff --git a/backend/genesys_gl124.h b/backend/genesys_gl124.h index 25f99c3..9ca6afd 100644 --- a/backend/genesys_gl124.h +++ b/backend/genesys_gl124.h @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2016 Stéphane Voltz This file is part of the SANE package. @@ -44,71 +44,71 @@ #include "genesys.h" #define REG01 0x01 -#define REG01_CISSET 0x80 -#define REG01_DOGENB 0x40 -#define REG01_DVDSET 0x20 +#define REG01_CISSET 0x80 +#define REG01_DOGENB 0x40 +#define REG01_DVDSET 0x20 #define REG01_STAGGER 0x10 -#define REG01_COMPENB 0x08 +#define REG01_COMPENB 0x08 #define REG01_TRUEGRAY 0x04 -#define REG01_SHDAREA 0x02 -#define REG01_SCAN 0x01 - -#define REG02 0x02 -#define REG02_NOTHOME 0x80 -#define REG02_ACDCDIS 0x40 -#define REG02_AGOHOME 0x20 -#define REG02_MTRPWR 0x10 -#define REG02_FASTFED 0x08 -#define REG02_MTRREV 0x04 -#define REG02_HOMENEG 0x02 -#define REG02_LONGCURV 0x01 +#define REG01_SHDAREA 0x02 +#define REG01_SCAN 0x01 + +#define REG02 0x02 +#define REG02_NOTHOME 0x80 +#define REG02_ACDCDIS 0x40 +#define REG02_AGOHOME 0x20 +#define REG02_MTRPWR 0x10 +#define REG02_FASTFED 0x08 +#define REG02_MTRREV 0x04 +#define REG02_HOMENEG 0x02 +#define REG02_LONGCURV 0x01 #define REG03 0x03 -#define REG03_LAMPDOG 0x80 -#define REG03_AVEENB 0x40 -#define REG03_XPASEL 0x20 -#define REG03_LAMPPWR 0x10 -#define REG03_LAMPTIM 0x0f - -#define REG04 0x04 -#define REG04_LINEART 0x80 -#define REG04_BITSET 0x40 -#define REG04_FILTER 0x30 +#define REG03_LAMPDOG 0x80 +#define REG03_AVEENB 0x40 +#define REG03_XPASEL 0x20 +#define REG03_LAMPPWR 0x10 +#define REG03_LAMPTIM 0x0f + +#define REG04 0x04 +#define REG04_LINEART 0x80 +#define REG04_BITSET 0x40 +#define REG04_FILTER 0x30 #define REG04_AFEMOD 0x07 -#define REG05 0x05 -#define REG05_DPIHW 0xc0 -#define REG05_DPIHW_600 0x00 -#define REG05_DPIHW_1200 0x40 -#define REG05_DPIHW_2400 0x80 -#define REG05_DPIHW_4800 0xc0 -#define REG05_MTLLAMP 0x30 -#define REG05_GMMENB 0x08 -#define REG05_ENB20M 0x04 -#define REG05_MTLBASE 0x03 - -#define REG06 0x06 -#define REG06_SCANMOD 0xe0 -#define REG06S_SCANMOD 5 -#define REG06_PWRBIT 0x10 -#define REG06_GAIN4 0x08 -#define REG06_OPTEST 0x07 - -#define REG07_LAMPSIM 0x80 - -#define REG08_DRAM2X 0x80 +#define REG05 0x05 +#define REG05_DPIHW 0xc0 +#define REG05_DPIHW_600 0x00 +#define REG05_DPIHW_1200 0x40 +#define REG05_DPIHW_2400 0x80 +#define REG05_DPIHW_4800 0xc0 +#define REG05_MTLLAMP 0x30 +#define REG05_GMMENB 0x08 +#define REG05_ENB20M 0x04 +#define REG05_MTLBASE 0x03 + +#define REG06 0x06 +#define REG06_SCANMOD 0xe0 +#define REG06S_SCANMOD 5 +#define REG06_PWRBIT 0x10 +#define REG06_GAIN4 0x08 +#define REG06_OPTEST 0x07 + +#define REG07_LAMPSIM 0x80 + +#define REG08_DRAM2X 0x80 #define REG08_MPENB 0x20 #define REG08_CIS_LINE 0x10 #define REG08_IR2_ENB 0x08 #define REG08_IR1_ENB 0x04 #define REG08_ENB24M 0x01 -#define REG09_MCNTSET 0xc0 +#define REG09_MCNTSET 0xc0 #define REG09_EVEN1ST 0x20 #define REG09_BLINE1ST 0x10 -#define REG09_BACKSCAN 0x08 -#define REG09_OUTINV 0x04 -#define REG09_SHORTTG 0x02 +#define REG09_BACKSCAN 0x08 +#define REG09_OUTINV 0x04 +#define REG09_SHORTTG 0x02 #define REG09S_MCNTSET 6 #define REG09S_CLKSET 4 @@ -136,55 +136,55 @@ #define REG0B_48MHZ 0x60 #define REG0B_60MHZ 0x80 -#define REG0D 0x0d +#define REG0D 0x0d #define REG0D_MTRP_RDY 0x80 #define REG0D_FULLSTP 0x10 #define REG0D_CLRMCNT 0x04 #define REG0D_CLRDOCJM 0x02 -#define REG0D_CLRLNCNT 0x01 - -#define REG0F 0x0f - -#define REG16_CTRLHI 0x80 -#define REG16_TOSHIBA 0x40 -#define REG16_TGINV 0x20 -#define REG16_CK1INV 0x10 -#define REG16_CK2INV 0x08 -#define REG16_CTRLINV 0x04 -#define REG16_CKDIS 0x02 -#define REG16_CTRLDIS 0x01 - -#define REG17_TGMODE 0xc0 -#define REG17_SNRSYN 0x0f - -#define REG18 0x18 -#define REG18_CNSET 0x80 -#define REG18_DCKSEL 0x60 -#define REG18_CKTOGGLE 0x10 -#define REG18_CKDELAY 0x0c -#define REG18_CKSEL 0x03 - -#define REG1A_SW2SET 0x80 -#define REG1A_SW1SET 0x40 -#define REG1A_MANUAL3 0x02 -#define REG1A_MANUAL1 0x01 -#define REG1A_CK4INV 0x08 -#define REG1A_CK3INV 0x04 -#define REG1A_LINECLP 0x02 +#define REG0D_CLRLNCNT 0x01 + +#define REG0F 0x0f + +#define REG16_CTRLHI 0x80 +#define REG16_TOSHIBA 0x40 +#define REG16_TGINV 0x20 +#define REG16_CK1INV 0x10 +#define REG16_CK2INV 0x08 +#define REG16_CTRLINV 0x04 +#define REG16_CKDIS 0x02 +#define REG16_CTRLDIS 0x01 + +#define REG17_TGMODE 0xc0 +#define REG17_SNRSYN 0x0f + +#define REG18 0x18 +#define REG18_CNSET 0x80 +#define REG18_DCKSEL 0x60 +#define REG18_CKTOGGLE 0x10 +#define REG18_CKDELAY 0x0c +#define REG18_CKSEL 0x03 + +#define REG1A_SW2SET 0x80 +#define REG1A_SW1SET 0x40 +#define REG1A_MANUAL3 0x02 +#define REG1A_MANUAL1 0x01 +#define REG1A_CK4INV 0x08 +#define REG1A_CK3INV 0x04 +#define REG1A_LINECLP 0x02 #define REG1C_TBTIME 0x07 -#define REG1D 0x1d -#define REG1D_CK4LOW 0x80 -#define REG1D_CK3LOW 0x40 -#define REG1D_CK1LOW 0x20 -#define REG1D_LINESEL 0x1f +#define REG1D 0x1d +#define REG1D_CK4LOW 0x80 +#define REG1D_CK3LOW 0x40 +#define REG1D_CK1LOW 0x20 +#define REG1D_LINESEL 0x1f #define REG1DS_LINESEL 0 #define REG1E 0x1e -#define REG1E_WDTIME 0xf0 +#define REG1E_WDTIME 0xf0 #define REG1ES_WDTIME 4 -#define REG1E_WDTIME 0xf0 +#define REG1E_WDTIME 0xf0 #define REG30 0x30 #define REG31 0x31 @@ -243,18 +243,18 @@ #define REGB1 0xb1 #define REGB2 0xb2 -#define REGB2_Z1MOD 0x1f +#define REGB2_Z1MOD 0x1f #define REGB3 0xb3 -#define REGB3_Z1MOD 0xff +#define REGB3_Z1MOD 0xff #define REGB4 0xb4 -#define REGB4_Z1MOD 0xff +#define REGB4_Z1MOD 0xff #define REGB5 0xb5 -#define REGB5_Z2MOD 0x1f +#define REGB5_Z2MOD 0x1f #define REGB6 0xb6 -#define REGB6_Z2MOD 0xff +#define REGB6_Z2MOD 0xff #define REGB7 0xb7 -#define REGB7_Z2MOD 0xff +#define REGB7_Z2MOD 0xff #define REG100 0x100 #define REG100_DOCSNR 0x80 @@ -537,6 +537,7 @@ typedef struct /** @brief gpio layout * describes initial gpio settings for a given model + * registers 0x31 to 0x38 */ static Gpio_layout gpios[]={ /* LiDE 110 */ @@ -547,6 +548,10 @@ static Gpio_layout gpios[]={ { 0x9f, 0x59, 0x01, 0x80, 0x5f, 0x01, 0x00 }, + /* LiDE 120 */ + { + 0x9f, 0x53, 0x01, 0x80, 0x5f, 0x01, 0x00 + }, }; typedef struct @@ -565,12 +570,13 @@ typedef struct } Memory_layout; static Memory_layout layouts[]={ - /* LIDE 110 */ - { + /* LIDE 110, 120 */ + { /* 0xd0 0xd1 0xd2 */ 0x0a, 0x15, 0x20, + /* 0xe0 0xe1 0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 */ 0x00, 0xac, 0x08, 0x55, 0x08, 0x56, 0x0f, 0xff }, - /* LIDE 210 */ + /* LIDE 210, 220 */ { 0x0a, 0x1f, 0x34, 0x01, 0x24, 0x08, 0x91, 0x08, 0x92, 0x0f, 0xff @@ -590,8 +596,8 @@ typedef struct { int half_ccd; /**> half ccd mode */ int exposure; /**> exposure */ int ck1map; /**> CK1MAP */ - int ck3map; /**> CK2MAP */ - int ck4map; /**> CK3MAP */ + int ck3map; /**> CK3MAP */ + int ck4map; /**> CK4MAP */ int segcnt; /**> SEGCNT */ int tg0cnt; /**> TG0CNT */ int expdummy; /**> exposure dummy */ @@ -603,6 +609,8 @@ typedef struct { uint8_t reg20; /**> register 0x20 value */ uint8_t reg61; /**> register 0x61 value */ uint8_t reg98; /**> register 0x98 value */ + uint8_t reg16; /**> register 0x16 value */ + uint8_t reg70; /**> register 0x70 value */ } Sensor_Profile; static size_t order_01[]={0,1}; @@ -610,58 +618,68 @@ static size_t order_0213[]={0,2,1,3}; /* *INDENT-OFF* */ -/** - * database of sensor profiles +/** @brief database of sensor profiles + * database of sensor profiles giving for each sensor and a given resolution, the period, and timings + * to setup the sensor for the scan. */ static Sensor_Profile sensors[]={ /* LiDE 110 */ - {CIS_CANONLIDE110, 600, 1, 2768, 0x1e, 0x9f, 0x55, 2584, 154, 101, 388, 574, 393, NULL , 0x00, 0x0c, 0x20, 0x21}, - {CIS_CANONLIDE110, 600, 0, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE110, 1200, 0, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, - {CIS_CANONLIDE110, 2400, 0, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, + {CIS_CANONLIDE110, 600, 1, 2768, 0x1e, 0x9f, 0x55, 2584, 154, 101, 388, 574, 393, NULL , 0x00, 0x0c, 0x20, 0x21, 0x00, 0x00}, + {CIS_CANONLIDE110, 600, 0, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21, 0x00, 0x00}, + {CIS_CANONLIDE110, 1200, 0, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22, 0x00, 0x00}, + {CIS_CANONLIDE110, 2400, 0, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24, 0x00, 0x00}, - /* LiDE 120 */ - {CIS_CANONLIDE120, 600, 1, 2768, 0x0f, 0x9f, 0x55, 2552, 112, 94, 388, 574, 393, NULL , 0x00, 0x02, 0x20, 0x21}, - {CIS_CANONLIDE120, 600, 0, 5360, 0x0f, 0x9f, 0x55, 5168, 163, 94, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE120, 1200, 0, 10528, 0x0f, 0x9f, 0x55, 5168, 163, 94, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, - {CIS_CANONLIDE120, 2400, 0, 20864, 0x0f, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, + /* LiDE 120 */ + {CIS_CANONLIDE120, 600, 1, 4608, 0x0f, 0x00, 0x55, 2552, 112, 94, 894, 1044, 994, NULL , 0x00, 0x02, 0x20, 0x21, 0x15, 0x00}, + {CIS_CANONLIDE120, 600, 0, 5360, 0x0f, 0x00, 0x55, 5104, 139, 94, 1644, 1994, 1844, NULL , 0x00, 0x02, 0x20, 0x21, 0x11, 0x1f}, + {CIS_CANONLIDE120, 1200, 0, 10528, 0x0f, 0x00, 0x55,10208, 192, 94, 3194, 3794, 3594, NULL , 0x00, 0x02, 0x20, 0x21, 0x15, 0x1f}, + {CIS_CANONLIDE120, 2400, 0, 20864, 0x0f, 0x00, 0x55,20416, 298, 94, 6244, 7544, 7094, NULL , 0x00, 0x02, 0x20, 0x21, 0x11, 0x00}, /* LiDE 210 */ - {CIS_CANONLIDE210, 600, 1, 2768, 0x1e, 0x9f, 0x55, 2584, 154, 101, 388, 574, 393, NULL , 0x00, 0x0c, 0x20, 0x21}, - {CIS_CANONLIDE210, 600, 0, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE210, 1200, 0, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, - {CIS_CANONLIDE210, 2400, 0, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, + {CIS_CANONLIDE210, 600, 1, 2768, 0x1e, 0x9f, 0x55, 2584, 154, 101, 388, 574, 393, NULL , 0x00, 0x0c, 0x20, 0x21, 0x00, 0x00}, + {CIS_CANONLIDE210, 600, 0, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21, 0x00, 0x00}, + {CIS_CANONLIDE210, 1200, 0, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22, 0x00, 0x00}, + {CIS_CANONLIDE210, 2400, 0, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24, 0x00, 0x00}, /* LiDE 220 */ - {CIS_CANONLIDE220, 600, 1, 2768, 0x0f, 0x9f, 0x55, 2584, 154, 101, 388, 574, 393, NULL , 0x00, 0x0c, 0x20, 0x21}, - {CIS_CANONLIDE220, 600, 0, 5360, 0x0f, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE220, 1200, 0, 10528, 0x0f, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, - {CIS_CANONLIDE220, 2400, 0, 20864, 0x0f, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, + {CIS_CANONLIDE220, 600, 1, 2768, 0x0f, 0x9f, 0x55, 2584, 154, 101, 388, 574, 393, NULL , 0x00, 0x0c, 0x20, 0x21, 0x00, 0x00}, + {CIS_CANONLIDE220, 600, 0, 5360, 0x0f, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21, 0x00, 0x00}, + {CIS_CANONLIDE220, 1200, 0, 10528, 0x0f, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22, 0x00, 0x00}, + {CIS_CANONLIDE220, 2400, 0, 20864, 0x0f, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24, 0x00, 0x00}, }; #define MOVE_DPI 200 #define MOVE_EXPOSURE 2304 - +/** @brief reference slope tables + * slope table directly extracted from USB logs, with a 'termination' value of 0. + */ static uint32_t lide210_fast[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1432, 1372, 1323, 1280, 1246, 1216, 1188, 1163, 1142, 1121, 1101, 1084, 1068, 1051, 1036, 1020, 1007, 995, 983, 971, 959, 949, 938, 929, 917, 908, 900, 891, 882, 874, 866, 857, 849, 843, 835, 829, 821, 816, 808, 802, 795, 789, 784, 778, 773, 765, 760, 755, 749, 744, 739, 734, 731, 726, 721, 716, 711, 707, 702, 698, 693, 690, 685, 682, 677, 672, 669, 665, 662, 657, 654, 650, 647, 644, 639, 637, 632, 629, 626, 622, 619, 617, 614, 610, 607, 604, 601, 599, 595, 592, 589, 587, 584, 581, 579, 576, 572, 570, 567, 564, 562, 559, 557, 554, 552, 549, 547, 544, 542, 539, 538, 536, 533, 531, 529, 526, 524, 522, 519, 518, 516, 513, 511, 509, 506, 505, 503, 501, 498, 497, 495, 493, 491, 490, 487, 485, 483, 482, 480, 477, 476, 474, 472, 470, 469, 467, 465, 464, 462, 460, 458, 456, 455, 453, 451, 450, 448, 447, 445, 444, 442, 440, 439, 437, 436, 434, 433, 431, 430, 428, 427, 425, 423, 422, 420, 419, 417, 417, 415, 414, 413, 411, 410, 408, 407, 405, 404, 402, 401, 400, 399, 398, 396, 395, 393, 392, 391, 390, 389, 387, 386, 385, 383, 382, 381, 380, 379, 377, 376, 375, 374, 373, 371, 370, 369, 368, 367, 366, 364, 363, 363, 361, 360, 359, 358, 357, 356, 355, 353, 352, 352, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 335, 335, 0}; -static uint32_t lide110_ok[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1961, 1901, 1852, 1809, 1775, 1745, 1717, 1692, 1671, 1650, 1630, 1613, 1597,1580,1565,1549,1536,1524,1512,1500,1488,1478,1467,1458,1446,1437,1429,1420,1411,1403,1395,1386,1378,1372,1364,1358,1350,1345,1337,1331,1324,1318,1313,1307,1302,1294,1289,1284,1278,1273,1268,1263,1260,1255,1250,1245,1240,1236,1231,1227,1222,1219,1214,1211,1206,1201,1198,1194,1191,1186,1183,1179,1176,1173,1168,1166,1161,1158,1155,1151,1148,1146,1143,1139,1136,1133,1130,1128,1124,1121,1118,1116,1113,1110,1108,1105,1101,1099,1096,1093,1091,1088,1086,1083,1081,1078,1076,1073,1071,1068,1067,1065,1062,1060,1058,1055,1053,1051,1048,1047,1045,1042,1040,1038,1035,1034,1032,1030,1027,1026,1024,1022,1020,1019,1016,1014,1012,1011,1009,1006,1005,1003,1001,999,998,996,994,993,991,989,987,985,984,982,980,979,977,976,974,973,971,969,968,966,965,963,962,960,959,957,956,954,952,951,949,948,946,946,944,943,942,940,939,937,936,934,933,931,930,929,928,927,925,924,922,921,920,919,918,916,915,914,912,911,910,909,908,906,905,904,903,902,900,899,898,897,896,895,893,892,892,890,889,888,887,886,885,884,882,881,881,879,878,877,876,875,874,873,872,871,870,869,868,867,864,857, 849, 843, 835, 829, 821, 816, 808, 802, 795, 789, 784, 778, 773, 765, 760, 755, 749, 744, 739, 734, 731, 726, 721, 716, 711, 707, 702, 698, 693, 690, 685, 682, 677, 672, 669, 665, 662, 657, 654, 650, 647, 644, 639, 637, 632, 629, 626, 622, 619, 617, 614, 610, 607, 604, 601, 599, 595, 592, 589, 587, 584, 581, 579, 576, 572, 570, 567, 564, 562, 559, 557, 554, 552, 549, 547, 544, 542, 539, 538, 536, 533, 531, 529, 526, 524, 522, 519, 518, 516, 513, 511, 509, 506, 505, 503, 501, 498, 497, 495, 493, 491, 490, 487, 485, 483, 482, 480, 477, 476, 474, 472, 470, 469, 467, 465, 464, 462, 460, 458, 456, 455, 453, 451, 450, 448, 447, 445, 444, 442, 440, 439, 437, 436, 434, 433, 431, 430, 428, 427, 425, 423, 422, 420, 419, 417, 417, 415, 414, 413, 411, 410, 408, 407, 405, 404, 402, 401, 400, 399, 398, 396, 395, 393, 392, 391, 390, 389, 387, 386, 385, 383, 382, 381, 380, 379, 377, 376, 375, 374, 373, 371, 370, 369, 368, 367, 366, 364, 363, 363, 361, 360, 359, 358, 357, 356, 355, 353, 352, 352, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 335, 335, 0}; +static uint32_t lide110_ok[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1961, 1901, 1852, 1809, 1775, 1745, 1717, 1692, 1671, 1650, 1630, 1613, 1597, 1580, 1565, 1549, 1536, 1524, 1512, 1500, 1488, 1478, 1467, 1458, 1446, 1437, 1429, 1420, 1411, 1403, 1395, 1386, 1378, 1372, 1364, 1358, 1350, 1345, 1337, 1331, 1324, 1318, 1313, 1307, 1302, 1294, 1289, 1284, 1278, 1273, 1268, 1263, 1260, 1255, 1250, 1245, 1240, 1236, 1231, 1227, 1222, 1219, 1214, 1211, 1206, 1201, 1198, 1194, 1191, 1186, 1183, 1179, 1176, 1173, 1168, 1166, 1161, 1158, 1155, 1151, 1148, 1146, 1143, 1139, 1136, 1133, 1130, 1128, 1124, 1121, 1118, 1116, 1113, 1110, 1108, 1105, 1101, 1099, 1096, 1093, 1091, 1088, 1086, 1083, 1081, 1078, 1076, 1073, 1071, 1068, 1067, 1065, 1062, 1060, 1058, 1055, 1053, 1051, 1048, 1047, 1045, 1042, 1040, 1038, 1035, 1034, 1032, 1030, 1027, 1026, 1024, 1022, 1020, 1019, 1016, 1014, 1012, 1011, 1009, 1006, 1005, 1003, 1001, 999, 998, 996, 994, 993, 991, 989, 987, 985, 984, 982, 980, 979, 977, 976, 974, 973, 971, 969, 968, 966, 965, 963, 962, 960, 959, 957, 956, 954, 952, 951, 949, 948, 946, 946, 944, 943, 942, 940, 939, 937, 936, 934, 933, 931, 930, 929, 928, 927, 925, 924, 922, 921, 920, 919, 918, 916, 915, 914, 912, 911, 910, 909, 908, 906, 905, 904, 903, 902, 900, 899, 898, 897, 896, 895, 893, 892, 892, 890, 889, 888, 887, 886, 885, 884, 882, 881, 881, 879, 878, 877, 876, 875, 874, 873, 872, 871, 870, 869, 868, 867, 864, 857, 849, 843, 835, 829, 821, 816, 808, 802, 795, 789, 784, 778, 773, 765, 760, 755, 749, 744, 739, 734, 731, 726, 721, 716, 711, 707, 702, 698, 693, 690, 685, 682, 677, 672, 669, 665, 662, 657, 654, 650, 647, 644, 639, 637, 632, 629, 626, 622, 619, 617, 614, 610, 607, 604, 601, 599, 595, 592, 589, 587, 584, 581, 579, 576, 572, 570, 567, 564, 562, 559, 557, 554, 552, 549, 547, 544, 542, 539, 538, 536, 533, 531, 529, 526, 524, 522, 519, 518, 516, 513, 511, 509, 506, 505, 503, 501, 498, 497, 495, 493, 491, 490, 487, 485, 483, 482, 480, 477, 476, 474, 472, 470, 469, 467, 465, 464, 462, 460, 458, 456, 455, 453, 451, 450, 448, 447, 445, 444, 442, 440, 439, 437, 436, 434, 433, 431, 430, 428, 427, 425, 423, 422, 420, 419, 417, 417, 415, 414, 413, 411, 410, 408, 407, 405, 404, 402, 401, 400, 399, 398, 396, 395, 393, 392, 391, 390, 389, 387, 386, 385, 383, 382, 381, 380, 379, 377, 376, 375, 374, 373, 371, 370, 369, 368, 367, 366, 364, 363, 363, 361, 360, 359, 358, 357, 356, 355, 353, 352, 352, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 335, 335, 0}; +static uint32_t lide120_fast[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 1957, 1845, 1768, 1710, 1665, 1624, 1588, 1557, 1529, 1504, 1481, 1458, 1440, 1420, 1403, 1386, 1370, 1356, 1343, 1329, 1316, 1303, 1293, 1280, 1270, 1260, 1250, 1241, 1231, 1222, 1214, 1206, 1197, 1189, 1182, 1174, 1167, 1160, 1153, 1147, 1140, 1133, 1128, 1121, 1116, 1110, 1104, 1099, 1093, 1088, 1082, 1077, 1072, 1067, 1062, 1058, 1053, 1049, 1045, 1040, 1035, 1032, 1027, 1023, 1020, 1015, 1012, 1008, 1004, 1000, 997, 993, 989, 985, 982, 979, 975, 972, 969, 966, 963, 959, 956, 953, 950, 947, 945, 942, 939, 936, 933, 930, 928, 925, 922, 920, 917, 914, 911, 909, 907, 904, 902, 899, 897, 895, 892, 890, 888, 886, 883, 881, 879, 876, 874, 872, 870, 864, 864, 0}; +static uint32_t lide120_ok[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2286, 2264, 2248, 2232, 2221, 2211, 2205, 2195, 2190, 2180, 2175, 2170, 2160, 2155, 2150, 2145, 2140, 2135, 2130, 2125, 2121, 2116, 2111, 2106, 2106, 2102, 2097, 2092, 2087, 2087, 2083, 2078, 2074, 2074, 2069, 2064, 2064, 2060, 2055, 2055, 2051, 2051, 2046, 2042, 2042, 2038, 2038, 2033, 2029, 2029, 2024, 2024, 2020, 2010, 2010, 670*2, 0}; static uint32_t lide110_slow[] = { 62496, 7896, 2632, 0}; +static uint32_t lide120_slow[] = { 62464, 7896, 2632, 0}; static uint32_t lide110_max[] = { 62496, 31296, 10432, 0}; +static uint32_t lide120_max[] = { 62592, 62592, 41728, 31296, 10432, 0}; static uint32_t lide210_max[] = { 62496, 31296, 20864, 10432, 0}; -/** - * database of motor profiles - */ - - /* NEXT LPERIOD=PREVIOUS*2-192 */ +/** @brief database of motor profiles + * database of motor profiles, for each exposure deigned for the sensor, gives the reference slope table to use + * for scan. + */ static Motor_Profile motors[]={ {MOTOR_CANONLIDE110, 2768, 0, lide210_fast}, - {MOTOR_CANONLIDE110, 5360, 0, lide110_ok}, + {MOTOR_CANONLIDE110, 5360, 1, lide110_ok}, {MOTOR_CANONLIDE110, 10528, 1, lide110_slow}, {MOTOR_CANONLIDE110, 20864, 2, lide110_max}, + {MOTOR_CANONLIDE120, 4608, 0, lide120_fast}, + {MOTOR_CANONLIDE120, 5360, 1, lide120_ok}, + {MOTOR_CANONLIDE120, 10528, 2, lide120_slow}, + {MOTOR_CANONLIDE120, 20864, 2, lide120_max}, {MOTOR_CANONLIDE210, 2768, 0, lide210_fast}, - {MOTOR_CANONLIDE210, 5360, 0, lide110_ok}, + {MOTOR_CANONLIDE210, 5360, 1, lide110_ok}, {MOTOR_CANONLIDE210, 10528, 1, lide110_slow}, {MOTOR_CANONLIDE210, 20864, 2, lide210_max}, {0, 0, 0, NULL}, @@ -670,10 +688,10 @@ static Motor_Profile motors[]={ GENESYS_STATIC SANE_Status gl124_init_scan_regs (Genesys_Device * dev, Genesys_Register_Set * reg, - float xres, /*dpi */ - float yres, /*dpi */ - float startx, /*optical_res, from dummy_pixel+1 */ - float starty, /*base_ydpi, from home! */ + float xres, /*dpi */ + float yres, /*dpi */ + float startx, /*optical_res, from dummy_pixel+1 */ + float starty, /*base_ydpi, from home! */ float pixels, float lines, unsigned int depth, diff --git a/backend/genesys_gl646.c b/backend/genesys_gl646.c index 19b4585..58952fb 100644 --- a/backend/genesys_gl646.c +++ b/backend/genesys_gl646.c @@ -3,7 +3,7 @@ Copyright (C) 2003 Oliver Rauch Copyright (C) 2003, 2004 Henning Meier-Geinitz Copyright (C) 2004 Gerhard Jaeger - Copyright (C) 2004-2013 Stéphane Voltz + Copyright (C) 2004-2013 Stéphane Voltz Copyright (C) 2005-2009 Pierre Willenbrock Copyright (C) 2007 Luke Copyright (C) 2011 Alexey Osipov for HP2400 description @@ -1999,7 +1999,7 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) /* Wolfson type frontend */ if ((dev->reg[reg_0x04].value & REG04_FESET) != 0x03) { - DBG (DBG_proc, "gl646_set_fe(): unspported frontend type %d\n", + DBG (DBG_proc, "gl646_set_fe(): unsupported frontend type %d\n", dev->reg[reg_0x04].value & REG04_FESET); return SANE_STATUS_UNSUPPORTED; } @@ -3066,7 +3066,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to setup for scan: %s\n", __FUNCTION__, + "%s: failed to setup for scan: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -3082,7 +3082,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to set frontend: %s\n", __FUNCTION__, + "%s: failed to set frontend: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -3429,7 +3429,7 @@ setup_for_scan (Genesys_Device * dev, DBG (DBG_info, "%s settings:\nResolution: %ux%uDPI\n" "Lines : %u\nPixels : %u\nStartpos : %.3f/%.3f\nScan mode : %d\nScan method: %s\n\n", - __FUNCTION__, + __func__, settings.xres, settings.yres, settings.lines, settings.pixels, settings.tl_x, settings.tl_y, settings.scan_mode, settings.scan_method == SCAN_METHOD_FLATBED ? "flatbed" : "XPA"); @@ -3482,16 +3482,16 @@ setup_for_scan (Genesys_Device * dev, move += (settings.tl_y * dev->motor.optical_ydpi) / MM_PER_INCH; } - DBG (DBG_info, "%s: move=%d steps\n", __FUNCTION__, move); + DBG (DBG_info, "%s: move=%d steps\n", __func__, move); /* security check */ if (move < 0) { - DBG (DBG_error, "%s: overriding negative move value %d\n", __FUNCTION__, move); + DBG (DBG_error, "%s: overriding negative move value %d\n", __func__, move); move = 0; } } - DBG (DBG_info, "%s: move=%d steps\n", __FUNCTION__, move); + DBG (DBG_info, "%s: move=%d steps\n", __func__, move); /* pixels are allways given at full CCD optical resolution */ /* use detected left margin and fixed value */ @@ -3550,7 +3550,7 @@ setup_for_scan (Genesys_Device * dev, depth); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed setup registers: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed setup registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -3585,7 +3585,7 @@ setup_for_scan (Genesys_Device * dev, sanei_genesys_read_reg_from_set (regs, 0x21)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send slope table 0: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to send slope table 0: %s\n", __func__, sane_strstatus (status)); return status; } @@ -3594,7 +3594,7 @@ setup_for_scan (Genesys_Device * dev, sanei_genesys_read_reg_from_set (regs, 0x6b)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send slope table 1: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to send slope table 1: %s\n", __func__, sane_strstatus (status)); return status; } @@ -4414,7 +4414,7 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { free(line); - DBG (DBG_error, "%s: failed to scan first line\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to scan first line\n", __func__); return status; } @@ -4472,7 +4472,7 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi) dev->frontend.gain[k]++; DBG (DBG_proc, - "%s: channel %d, average = %.2f, gain = %d\n", __FUNCTION__, + "%s: channel %d, average = %.2f, gain = %d\n", __func__, k, average[k], dev->frontend.gain[k]); } free (line); @@ -4484,7 +4484,7 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi) dev->frontend.gain[2] = dev->frontend.gain[0]; } - DBG (DBG_info, "%s: gains=(%d,%d,%d)\n", __FUNCTION__, + DBG (DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1], dev->frontend.gain[2]); DBGCOMPLETED; return status; @@ -5767,6 +5767,7 @@ static Genesys_Command_Set gl646_cmd_set = { gl646_led_calibration, gl646_slow_back_home, + NULL, gl646_bulk_write_register, gl646_bulk_write_data, diff --git a/backend/genesys_gl646.h b/backend/genesys_gl646.h index 9e328c5..4c47d03 100644 --- a/backend/genesys_gl646.h +++ b/backend/genesys_gl646.h @@ -2,7 +2,7 @@ Copyright (C) 2003-2004 Henning Meier-Geinitz Copyright (C) 2004-2005 Gerhard Jaeger - Copyright (C) 2004-2013 Stéphane Voltz + Copyright (C) 2004-2013 Stéphane Voltz Copyright (C) 2005-2009 Pierre Willenbrock This file is part of the SANE package. @@ -276,10 +276,10 @@ gl646_move_to_ta (Genesys_Device * dev); /** * sets up the scanner for a scan, registers, gamma tables, shading tables * and slope tables, based on the parameter struct. - * @param device device to set up - * @param regs registers to set up - * @param settings settings of the scan - * @param split true if move before scan has to be done + * @param dev device to set up + * @param regs registers to set up + * @param settings settings of the scan + * @param split true if move before scan has to be done * @param xcorrection true if scanner's X geometry must be taken into account to * compute X, ie add left margins * @param ycorrection true if scanner's Y geometry must be taken into account to diff --git a/backend/genesys_gl841.c b/backend/genesys_gl841.c index 2b16c67..43c01ff 100644 --- a/backend/genesys_gl841.c +++ b/backend/genesys_gl841.c @@ -3,7 +3,7 @@ Copyright (C) 2003 Oliver Rauch Copyright (C) 2003, 2004 Henning Meier-Geinitz Copyright (C) 2004 Gerhard Jaeger - Copyright (C) 2004-2013 Stéphane Voltz + Copyright (C) 2004-2013 Stéphane Voltz Copyright (C) 2005 Philipp Schmid Copyright (C) 2005-2009 Pierre Willenbrock Copyright (C) 2006 Laurent Charpentier @@ -204,7 +204,7 @@ printtime(char *p) { gettimeofday(&t,NULL); dif = t.tv_sec - start_time.tv_sec; dif = dif*1000000 + t.tv_usec - start_time.tv_usec; - fprintf(stderr,"%s %lluµs\n",p,dif); + fprintf(stderr,"%s %lluµs\n",p,dif); } */ @@ -1158,7 +1158,7 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr, { sprintf (msg+strlen(msg), ",%d", slope_table[i]); } - DBG (DBG_io, "%s: %s\n", __FUNCTION__, msg); + DBG (DBG_io, "%s: %s\n", __func__, msg); } status = @@ -1204,7 +1204,7 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set) if (set == AFE_INIT) { - DBG (DBG_proc, "%s(): setting DAC %u\n", __FUNCTION__, + DBG (DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); /* sets to default values */ @@ -1214,21 +1214,21 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x00 failed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus (status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.reg[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x03 failed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: writing reg 0x03 failed: %s\n", __func__, sane_strstatus (status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.reg[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x06 failed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: writing reg 0x06 failed: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1239,21 +1239,21 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x00 failed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus (status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.offset[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing offset failed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: writing offset failed: %s\n", __func__, sane_strstatus (status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.gain[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing gain failed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: writing gain failed: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1734,7 +1734,7 @@ gl841_init_motor_regs(Genesys_Device * dev, 0, 0, &scan_power_mode); - DBG (DBG_info, "%s : fast_exposure=%d pixels\n", __FUNCTION__, fast_exposure); + DBG (DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); } if (action == MOTOR_ACTION_HOME_FREE) { @@ -1911,7 +1911,7 @@ gl841_init_motor_regs_scan(Genesys_Device * dev, 0, &dummy_power_mode); - DBG (DBG_info, "%s : fast_exposure=%d pixels\n", __FUNCTION__, fast_exposure); + DBG (DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); memset(slow_slope_table,0xff,512); @@ -2453,7 +2453,7 @@ gl841_init_optical_regs_scan(Genesys_Device * dev, sanei_genesys_set_double(reg, REG_DPISET, dpiset); sanei_genesys_set_double(reg, REG_STRPIXEL, start); sanei_genesys_set_double(reg, REG_ENDPIXEL, end); - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n",__FUNCTION__,start,end); + DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n",__func__,start,end); /* words(16bit) before gamma, conversion to 8 bit or lineart*/ words_per_line = (pixels * dpiset) / gl841_get_dpihw(dev); @@ -2794,7 +2794,7 @@ dummy \ scanned lines start, used_pixels, &scan_power_mode); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time); + DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /*** optical parameters ***/ /* in case of dynamic lineart, we use an internal 8 bit gray scan @@ -3160,7 +3160,7 @@ dummy \ scanned lines start, used_pixels, &scan_power_mode); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time); + DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /* scanned area must be enlarged by max color shift needed */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); @@ -3451,7 +3451,7 @@ gl841_stop_action (Genesys_Device * dev) uint8_t val40, val; unsigned int loop; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); status = sanei_genesys_get_status (dev, &val); if (DBG_LEVEL >= DBG_io) @@ -3463,7 +3463,7 @@ gl841_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n",__FUNCTION__, + "%s: failed to read home sensor: %s\n",__func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -3472,7 +3472,7 @@ gl841_stop_action (Genesys_Device * dev) /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __FUNCTION__); + DBG (DBG_info, "%s: already stopped\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -3485,7 +3485,7 @@ gl841_stop_action (Genesys_Device * dev) status = gl841_bulk_write_register (dev, local_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -3505,7 +3505,7 @@ gl841_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n",__FUNCTION__, + "%s: failed to read home sensor: %s\n",__func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -3557,7 +3557,7 @@ gl841_eject_document (Genesys_Device * dev) DBG (DBG_proc, "gl841_eject_document\n"); - if (!dev->model->is_sheetfed == SANE_TRUE) + if (dev->model->is_sheetfed == SANE_FALSE) { DBG (DBG_proc, "gl841_eject_document: there is no \"eject sheet\"-concept for non sheet fed\n"); DBG (DBG_proc, "gl841_eject_document: finished\n"); @@ -3762,14 +3762,14 @@ gl841_detect_document_end (Genesys_Device * dev) uint8_t val; size_t total_bytes_to_read; - DBG (DBG_proc, "%s: begin\n", __FUNCTION__); + DBG (DBG_proc, "%s: begin\n", __func__); RIE (gl841_get_paper_sensor (dev, &paper_loaded)); /* sheetfed scanner uses home sensor as paper present */ if ((dev->document == SANE_TRUE) && !paper_loaded) { - DBG (DBG_info, "%s: no more document\n", __FUNCTION__); + DBG (DBG_info, "%s: no more document\n", __func__); dev->document = SANE_FALSE; /* we can't rely on total_bytes_to_read since the frontend @@ -3781,14 +3781,14 @@ gl841_detect_document_end (Genesys_Device * dev) { dev->total_bytes_to_read = dev->total_bytes_read; dev->read_bytes_left = 0; - DBG (DBG_proc, "%s: finished\n", __FUNCTION__); + DBG (DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } if (dev->settings.scan_mode == SCAN_MODE_COLOR && dev->model->is_cis) { scancnt/=3; } - DBG (DBG_io, "%s: scancnt=%u lines\n",__FUNCTION__, scancnt); + DBG (DBG_io, "%s: scancnt=%u lines\n",__func__, scancnt); RIE(sanei_genesys_read_register(dev, 0x25, &val)); lincnt=65536*val; @@ -3796,26 +3796,26 @@ gl841_detect_document_end (Genesys_Device * dev) lincnt+=256*val; RIE(sanei_genesys_read_register(dev, 0x27, &val)); lincnt+=val; - DBG (DBG_io, "%s: lincnt=%u lines\n",__FUNCTION__, lincnt); + DBG (DBG_io, "%s: lincnt=%u lines\n",__func__, lincnt); postcnt=(SANE_UNFIX(dev->model->post_scan)/MM_PER_INCH)*dev->settings.yres; - DBG (DBG_io, "%s: postcnt=%u lines\n",__FUNCTION__, postcnt); + DBG (DBG_io, "%s: postcnt=%u lines\n",__func__, postcnt); /* the current scancnt is also the final one, so we use it to * compute total bytes to read. We also add the line count to eject document */ total_bytes_to_read=(scancnt+postcnt)*dev->wpl; - DBG (DBG_io, "%s: old total_bytes_to_read=%u\n",__FUNCTION__,(unsigned int)dev->total_bytes_to_read); - DBG (DBG_io, "%s: new total_bytes_to_read=%u\n",__FUNCTION__,(unsigned int)total_bytes_to_read); + DBG (DBG_io, "%s: old total_bytes_to_read=%u\n",__func__,(unsigned int)dev->total_bytes_to_read); + DBG (DBG_io, "%s: new total_bytes_to_read=%u\n",__func__,(unsigned int)total_bytes_to_read); /* assign new end value */ if(dev->total_bytes_to_read>total_bytes_to_read) { - DBG (DBG_io, "%s: scan shorten\n",__FUNCTION__); + DBG (DBG_io, "%s: scan shorten\n",__func__); dev->total_bytes_to_read=total_bytes_to_read; } } - DBG (DBG_proc, "%s: finished\n", __FUNCTION__); + DBG (DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -4184,7 +4184,7 @@ gl841_search_start_position (Genesys_Device * dev) SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE); if(status!=SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to init scan registers: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to init scan registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -4194,7 +4194,7 @@ gl841_search_start_position (Genesys_Device * dev) gl841_bulk_write_register (dev, local_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -4346,7 +4346,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev) float starty=0; DBGSTART; - DBG (DBG_proc, "%s: lines = %d\n", __FUNCTION__, (int)(dev->calib_lines)); + DBG (DBG_proc, "%s: lines = %d\n", __func__, (int)(dev->calib_lines)); /* initial calibration reg values */ memcpy (dev->calib_reg, dev->reg, GENESYS_GL841_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -4383,7 +4383,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -4393,7 +4393,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev) status = gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -4491,7 +4491,7 @@ gl841_init_regs_for_scan (Genesys_Device * dev) if(dev->model->is_cis && dev->settings.true_gray && dev->settings.scan_mode != SCAN_MODE_COLOR) { - DBG (DBG_io, "%s: activating LEDADD\n", __FUNCTION__); + DBG (DBG_io, "%s: activating LEDADD\n", __func__); flags |= SCAN_FLAG_ENABLE_LEDADD; } @@ -4610,11 +4610,11 @@ gl841_led_calibration (Genesys_Device * dev) { move = SANE_UNFIX (dev->model->y_offset_calib); move = (move * (dev->motor.base_ydpi)) / MM_PER_INCH; - DBG (DBG_io, "%s: move=%d lines\n", __FUNCTION__, move); + DBG (DBG_io, "%s: move=%d lines\n", __func__, move); status = gl841_feed(dev, move); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to feed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to feed: %s\n", __func__, sane_strstatus (status)); return status; } @@ -4644,7 +4644,7 @@ gl841_led_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to setup scan: %s\n", __FUNCTION__, + "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -4694,7 +4694,7 @@ gl841_led_calibration (Genesys_Device * dev) RIE (gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS)); - DBG (DBG_info, "%s: starting line reading\n", __FUNCTION__); + DBG (DBG_info, "%s: starting line reading\n", __func__); RIE (gl841_begin_scan (dev, dev->calib_reg, SANE_TRUE)); RIE (sanei_genesys_read_data_from_scanner (dev, line, total_size)); @@ -4727,7 +4727,7 @@ gl841_led_calibration (Genesys_Device * dev) avg[j] /= num_pixels; } - DBG(DBG_info,"%s: average: %d,%d,%d\n", __FUNCTION__, avg[0], avg[1], avg[2]); + DBG(DBG_info,"%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); acceptable = SANE_TRUE; @@ -4798,7 +4798,7 @@ gl841_led_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG(DBG_info,"%s: acceptable exposure: %d,%d,%d\n", __FUNCTION__, exp[0],exp[1],exp[2]); + DBG(DBG_info,"%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0],exp[1],exp[2]); /* cleanup before return */ free (line); @@ -4891,7 +4891,7 @@ ad_fe_offset_calibration (Genesys_Device * dev) dev->frontend.offset[2] = (top+bottom)/2; /* scan line */ - DBG (DBG_info, "%s: starting line reading\n",__FUNCTION__); + DBG (DBG_info, "%s: starting line reading\n",__func__); gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS); gl841_set_fe(dev, AFE_SET); gl841_begin_scan (dev, dev->calib_reg, SANE_TRUE); @@ -4909,7 +4909,7 @@ ad_fe_offset_calibration (Genesys_Device * dev) average+=line[i]; } average/=total_size; - DBG (DBG_data, "%s: average=%d\n", __FUNCTION__, average); + DBG (DBG_data, "%s: average=%d\n", __func__, average); /* if min value is above target, the current value becomes the new top * else it is the new bottom */ @@ -4928,7 +4928,7 @@ ad_fe_offset_calibration (Genesys_Device * dev) dev->frontend.offset[1]=0; dev->frontend.offset[2]=0; free(line); - DBG (DBG_info, "%s: offset=(%d,%d,%d)\n", __FUNCTION__, + DBG (DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], dev->frontend.offset[1], dev->frontend.offset[2]); @@ -5374,18 +5374,18 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) int lines=1; int move; - DBG (DBG_proc, "%s: dpi=%d\n", __FUNCTION__, dpi); + DBG (DBG_proc, "%s: dpi=%d\n", __func__, dpi); /* feed to white strip if needed */ if (dev->model->y_offset_calib>0) { move = SANE_UNFIX (dev->model->y_offset_calib); move = (move * (dev->motor.base_ydpi)) / MM_PER_INCH; - DBG (DBG_io, "%s: move=%d lines\n", __FUNCTION__, move); + DBG (DBG_io, "%s: move=%d lines\n", __func__, move); status = gl841_feed(dev, move); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to feed: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to feed: %s\n", __func__, sane_strstatus (status)); return status; } @@ -5414,7 +5414,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -5475,7 +5475,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) dev->frontend.gain[j] = gain[j]*12; } - DBG (DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __FUNCTION__, + DBG (DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j],dev->frontend.gain[j]); } @@ -5516,7 +5516,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) } free (line); - DBG (DBG_info, "%s: gain=(%d,%d,%d)\n", __FUNCTION__, + DBG (DBG_info, "%s: gain=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1], dev->frontend.gain[2]); @@ -5663,7 +5663,7 @@ gl841_is_compatible_calibration (Genesys_Device * dev, if ((time.tv_sec - cache->last_calibration > 30 * 60) && (dev->model->is_sheetfed == SANE_FALSE)) { - DBG (DBG_proc, "%s: expired entry, non compatible cache\n",__FUNCTION__); + DBG (DBG_proc, "%s: expired entry, non compatible cache\n",__func__); return SANE_STATUS_UNSUPPORTED; } } @@ -5969,7 +5969,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, "%s: failed to setup for scan: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -6208,7 +6208,7 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t *buffer,*ptr,*src; DBGSTART; - DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__FUNCTION__,size); + DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__func__,size); /* old method if no SHDAREA */ if((dev->reg[reg_0x01].value & REG01_SHDAREA) == 0) @@ -6217,7 +6217,7 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = sanei_genesys_set_buffer_address (dev, 0x0000); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set buffer address: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus (status)); return status; } @@ -6226,7 +6226,7 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading table: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to send shading table: %s\n", __func__, sane_strstatus (status)); return status; } @@ -6238,14 +6238,14 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) length = (uint32_t) (size / 3); sanei_genesys_get_double(dev->reg,REG_STRPIXEL,&strpixel); sanei_genesys_get_double(dev->reg,REG_ENDPIXEL,&endpixel); - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d\n",__FUNCTION__,strpixel,endpixel,endpixel-strpixel); + DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d\n",__func__,strpixel,endpixel,endpixel-strpixel); /* compute deletion/average factor */ sanei_genesys_get_double(dev->reg,REG_DPISET,&dpiset); dpihw = gl841_get_dpihw(dev); half=dev->current_setup.half_ccd+1; factor=dpihw/dpiset; - DBG( DBG_io2, "%s: dpihw=%d, dpiset=%d, half_ccd=%d, factor=%d\n",__FUNCTION__,dpihw,dpiset,half-1,factor); + DBG( DBG_io2, "%s: dpihw=%d, dpiset=%d, half_ccd=%d, factor=%d\n",__func__,dpihw,dpiset,half-1,factor); /* binary data logging */ if(DBG_LEVEL>=DBG_data) @@ -6269,11 +6269,11 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) */ beginpixel = dev->sensor.CCD_start_xoffset / half; beginpixel += dev->sensor.dummy_pixel + 1; - DBG(DBG_io2, "%s: ORIGIN PIXEL=%d\n", __FUNCTION__, beginpixel); + DBG(DBG_io2, "%s: ORIGIN PIXEL=%d\n", __func__, beginpixel); beginpixel = (strpixel-beginpixel*2*2)/factor; - DBG(DBG_io2, "%s: BEGIN PIXEL=%d\n",__FUNCTION__,beginpixel/4); + DBG(DBG_io2, "%s: BEGIN PIXEL=%d\n",__func__,beginpixel/4); - DBG(DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n",__FUNCTION__,length, length/4); + DBG(DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n",__func__,length, length/4); buffer=(uint8_t *)malloc(pixels); memset(buffer,0,pixels); @@ -6352,6 +6352,7 @@ static Genesys_Command_Set gl841_cmd_set = { gl841_led_calibration, gl841_slow_back_home, + NULL, gl841_bulk_write_register, gl841_bulk_write_data, diff --git a/backend/genesys_gl841.h b/backend/genesys_gl841.h index bbb79f1..d1bd07e 100644 --- a/backend/genesys_gl841.h +++ b/backend/genesys_gl841.h @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2011-2013 Stéphane Voltz + Copyright (C) 2011-2013 Stéphane Voltz This file is part of the SANE package. diff --git a/backend/genesys_gl843.c b/backend/genesys_gl843.c index 2b0d8fa..b47fb7e 100644 --- a/backend/genesys_gl843.c +++ b/backend/genesys_gl843.c @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2013 Stéphane Voltz This file is part of the SANE package. @@ -376,7 +376,7 @@ gl843_get_step_multiplier (Genesys_Register_Set * regs) value = 1; } } - DBG (DBG_io, "%s: step multiplier is %d\n", __FUNCTION__, value); + DBG (DBG_io, "%s: step multiplier is %d\n", __func__, value); return value; } @@ -452,7 +452,7 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi, int flags) /* default fallback */ if(idx<0) { - DBG (DBG_warn,"%s: using default sensor profile\n",__FUNCTION__); + DBG (DBG_warn,"%s: using default sensor profile\n",__func__); idx=0; } @@ -790,7 +790,7 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr, int i; char msg[10000]; - DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __FUNCTION__, + DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __func__, table_nr, steps); table = (uint8_t *) malloc (steps * 2); @@ -807,7 +807,7 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr, { sprintf (msg+strlen(msg), "%d", slope_table[i]); } - DBG (DBG_io, "%s: %s\n", __FUNCTION__, msg); + DBG (DBG_io, "%s: %s\n", __func__, msg); } @@ -818,7 +818,7 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr, { DBG (DBG_error, "%s: write data failed writing slope table %d (%s)\n", - __FUNCTION__, table_nr, sane_strstatus (status)); + __func__, table_nr, sane_strstatus (status)); } free (table); @@ -957,7 +957,7 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, lincnt=scan_lines; sanei_genesys_set_triple(reg,REG_LINCNT,lincnt); - DBG (DBG_io, "%s: lincnt=%d\n", __FUNCTION__, lincnt); + DBG (DBG_io, "%s: lincnt=%d\n", __func__, lincnt); /* compute register 02 value */ r = sanei_genesys_get_address (reg, REG02); @@ -1036,7 +1036,7 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, { dist += fast_steps*2; } - DBG (DBG_io2, "%s: acceleration distance=%d\n", __FUNCTION__, dist); + DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* get sure when don't insane value : XXX STEF XXX in this case we should * fall back to single table move */ @@ -1046,7 +1046,7 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, feedl = 1; sanei_genesys_set_triple(reg,REG_FEEDL,feedl); - DBG (DBG_io, "%s: feedl=%d\n", __FUNCTION__, feedl); + DBG (DBG_io, "%s: feedl=%d\n", __func__, feedl); /* doesn't seem to matter that much */ sanei_genesys_calculate_zmode2 (use_fast_fed, @@ -1179,13 +1179,13 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, { tgtime=2; } - DBG (DBG_io2, "%s: tgtime=%d\n", __FUNCTION__, tgtime); + DBG (DBG_io2, "%s: tgtime=%d\n", __func__, tgtime); /* to manage high resolution device while keeping good * low resolution scanning speed, we make hardware dpi vary */ dpihw=sanei_genesys_compute_dpihw(dev, used_res); factor=dev->sensor.optical_res/dpihw; - DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __FUNCTION__, dpihw, factor); + DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); /* sensor parameters */ gl843_setup_sensor (dev, reg, dpihw, flags); @@ -1193,7 +1193,7 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, /* resolution is divided according to CKSEL which is known once sensor is set up */ r = sanei_genesys_get_address (reg, REG18); cksel= (r->value & REG18_CKSEL)+1; - DBG (DBG_io2, "%s: cksel=%d\n", __FUNCTION__, cksel); + DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel); dpiset = used_res * cksel; /* start and end coordinate in optical dpi coordinates */ @@ -1218,7 +1218,7 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, status = gl843_set_fe (dev, AFE_SET); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set frontend: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1329,12 +1329,12 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, if(half_ccd) { sanei_genesys_set_double(reg,REG_DPISET,dpiset*4); - DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset*4); + DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset*4); } else { sanei_genesys_set_double(reg,REG_DPISET,dpiset); - DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset); + DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); } sanei_genesys_set_double(reg,REG_STRPIXEL,startx/tgtime); @@ -1355,22 +1355,22 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, dev->wpl = words_per_line; dev->bpl = words_per_line; - DBG (DBG_io2, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); - DBG (DBG_io2, "%s: pixels =%d\n", __FUNCTION__, pixels); - DBG (DBG_io2, "%s: depth =%d\n", __FUNCTION__, depth); - DBG (DBG_io2, "%s: dev->bpl =%lu\n", __FUNCTION__, (unsigned long) dev->bpl); - DBG (DBG_io2, "%s: dev->len =%lu\n", __FUNCTION__, (unsigned long)dev->len); - DBG (DBG_io2, "%s: dev->dist =%lu\n", __FUNCTION__, (unsigned long)dev->dist); + DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels); + DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); + DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); + DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->bpl); + DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); + DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); words_per_line *= channels; /* MAXWD is expressed in 2 words unit */ /* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */ sanei_genesys_set_triple(reg,REG_MAXWD,(words_per_line)>>1); - DBG (DBG_io2, "%s: words_per_line used=%d\n", __FUNCTION__, words_per_line); + DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); sanei_genesys_set_double(reg,REG_LPERIOD,exposure/tgtime); - DBG (DBG_io2, "%s: exposure used=%d\n", __FUNCTION__, exposure/tgtime); + DBG (DBG_io2, "%s: exposure used=%d\n", __func__, exposure/tgtime); r = sanei_genesys_get_address (reg, REG_DUMMY); r->value = dev->sensor.dummy_pixel * tgtime; @@ -1456,7 +1456,7 @@ gl843_init_scan_regs (Genesys_Device * dev, { stagger = (4 * yres) / dev->motor.base_ydpi; } - DBG (DBG_info, "%s : stagger=%d lines\n", __FUNCTION__, stagger); + DBG (DBG_info, "%s : stagger=%d lines\n", __func__, stagger); /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode @@ -1498,7 +1498,7 @@ gl843_init_scan_regs (Genesys_Device * dev, /* compute correct pixels number */ used_pixels = (pixels * optical_res) / xres; - DBG (DBG_info, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); + DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* round up pixels number if needed */ if (used_pixels * xres < pixels * optical_res) @@ -1531,8 +1531,8 @@ gl843_init_scan_regs (Genesys_Device * dev, scan_step_type = sanei_genesys_compute_step_type(gl843_motors, dev->model->motor_type, exposure); } - DBG (DBG_info, "%s : exposure=%d pixels\n", __FUNCTION__, exposure); - DBG (DBG_info, "%s : scan_step_type=%d\n", __FUNCTION__, scan_step_type); + DBG (DBG_info, "%s : exposure=%d pixels\n", __func__, exposure); + DBG (DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type); /*** optical parameters ***/ /* in case of dynamic lineart, we use an internal 8 bit gray scan @@ -1652,7 +1652,7 @@ gl843_init_scan_regs (Genesys_Device * dev, dev->current_setup.pixels = (used_pixels * used_res) / optical_res; - DBG (DBG_info, "%s: current_setup.pixels=%d\n", __FUNCTION__, dev->current_setup.pixels); + DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.depth = depth; dev->current_setup.channels = channels; @@ -1777,7 +1777,7 @@ gl843_calculate_current_setup (Genesys_Device * dev) stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "%s: stagger=%d lines\n", __FUNCTION__, stagger); + DBG (DBG_info, "%s: stagger=%d lines\n", __func__, stagger); if(xres<=optical_res) used_res = xres; @@ -1790,11 +1790,11 @@ gl843_calculate_current_setup (Genesys_Device * dev) /* compute correct pixels number */ used_pixels = (pixels * optical_res) / xres; - DBG (DBG_info, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); + DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* exposure */ exposure = gl843_compute_exposure (dev, used_res, oflags); - DBG (DBG_info, "%s : exposure=%d pixels\n", __FUNCTION__, exposure); + DBG (DBG_info, "%s : exposure=%d pixels\n", __func__, exposure); /* it seems base_dpi of the G4050 motor is changed above 600 dpi*/ if (dev->model->motor_type == MOTOR_G4050 && yres>600) @@ -1817,7 +1817,7 @@ gl843_calculate_current_setup (Genesys_Device * dev) lincnt = lines + max_shift + stagger; dev->current_setup.pixels = (used_pixels * used_res) / optical_res; - DBG (DBG_info, "%s: current_setup.pixels=%d\n", __FUNCTION__, dev->current_setup.pixels); + DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.depth = depth; dev->current_setup.channels = channels; @@ -1944,7 +1944,7 @@ gl843_stop_action (Genesys_Device * dev) uint8_t val40, val; unsigned int loop; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); status = sanei_genesys_get_status (dev, &val); if (DBG_LEVEL >= DBG_io) @@ -1957,17 +1957,17 @@ gl843_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); - DBG (DBG_proc, "%s: completed\n", __FUNCTION__); + DBG (DBG_proc, "%s: completed\n", __func__); return status; } /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __FUNCTION__); - DBG (DBG_proc, "%s: completed\n", __FUNCTION__); + DBG (DBG_info, "%s: already stopped\n", __func__); + DBG (DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -1978,7 +1978,7 @@ gl843_stop_action (Genesys_Device * dev) status = sanei_genesys_write_register (dev, REG01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to write register 01: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1997,7 +1997,7 @@ gl843_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -2042,7 +2042,7 @@ gl843_get_paper_sensor (Genesys_Device * dev, SANE_Bool * paper_loaded) static SANE_Status gl843_eject_document (Genesys_Device * dev) { - DBG (DBG_proc, "%s: not implemented \n", __FUNCTION__); + DBG (DBG_proc, "%s: not implemented \n", __func__); if (dev == NULL) return SANE_STATUS_INVAL; return SANE_STATUS_GOOD; @@ -2052,7 +2052,7 @@ gl843_eject_document (Genesys_Device * dev) static SANE_Status gl843_load_document (Genesys_Device * dev) { - DBG (DBG_proc, "%s: not implemented \n", __FUNCTION__); + DBG (DBG_proc, "%s: not implemented \n", __func__); if (dev == NULL) return SANE_STATUS_INVAL; return SANE_STATUS_GOOD; @@ -2071,14 +2071,14 @@ gl843_detect_document_end (Genesys_Device * dev) unsigned int scancnt = 0; int flines, channels, depth, bytes_remain, sublines, bytes_to_flush, lines, sub_bytes, tmp, read_bytes_left; - DBG (DBG_proc, "%s: begin\n", __FUNCTION__); + DBG (DBG_proc, "%s: begin\n", __func__); RIE (gl843_get_paper_sensor (dev, &paper_loaded)); /* sheetfed scanner uses home sensor as paper present */ if ((dev->document == SANE_TRUE) && !paper_loaded) { - DBG (DBG_info, "%s: no more document\n", __FUNCTION__); + DBG (DBG_info, "%s: no more document\n", __func__); dev->document = SANE_FALSE; channels = dev->current_setup.channels; @@ -2193,7 +2193,7 @@ gl843_detect_document_end (Genesys_Device * dev) } } - DBG (DBG_proc, "%s: finished\n", __FUNCTION__); + DBG (DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -2483,7 +2483,7 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) status = gl843_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n",__FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to start motor: %s\n",__func__, sane_strstatus (status)); gl843_stop_action (dev); /* restore original registers */ dev->model->cmd_set->bulk_write_register (dev, dev->reg, GENESYS_GL843_MAX_REGS); @@ -2496,7 +2496,7 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n",__FUNCTION__, + "%s: failed to read home sensor: %s\n",__func__, sane_strstatus (status)); return status; } @@ -2507,8 +2507,8 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) if (val & REG41_HOMESNR) /* home sensor */ { - DBG (DBG_info, "%s: reached home position\n",__FUNCTION__); - DBG (DBG_proc, "%s: finished\n",__FUNCTION__); + DBG (DBG_info, "%s: reached home position\n",__func__); + DBG (DBG_proc, "%s: finished\n",__func__); /* clear GPOADF to avoid reparking again */ sanei_genesys_read_register (dev, REG6B, &val); @@ -2524,7 +2524,7 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) } /* we are not parked here.... should we fail ? */ - DBG (DBG_info, "%s: XPA lamp is not parked\n", __FUNCTION__); + DBG (DBG_info, "%s: XPA lamp is not parked\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -2564,7 +2564,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to read home sensor: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); return status; } usleep (100000); /* sleep 100 ms */ @@ -2674,7 +2674,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) return SANE_STATUS_IO_ERROR; } - DBG (DBG_info, "%s: scanhead is still moving\n", __FUNCTION__); + DBG (DBG_info, "%s: scanhead is still moving\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -2926,7 +2926,7 @@ gl843_feed (Genesys_Device * dev, unsigned int steps) status = gl843_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); gl843_stop_action (dev); /* restore original registers */ @@ -3000,7 +3000,7 @@ gl843_init_regs_for_shading (Genesys_Device * dev) dev->scanhead_position_in_steps += dev->calib_lines + move; sanei_genesys_get_double(dev->calib_reg,REG_STRPIXEL,&strpixel); - DBG (DBG_info, "%s: STRPIXEL=%d\n", __FUNCTION__, strpixel); + DBG (DBG_info, "%s: STRPIXEL=%d\n", __func__, strpixel); status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS); if (status != SANE_STATUS_GOOD) @@ -3380,9 +3380,9 @@ dark_average_channel (uint8_t * data, unsigned int pixels, unsigned int lines, } if (count) avg[k] /= count; - DBG (DBG_info, "%s: avg[%d] = %d\n", __FUNCTION__, k, avg[k]); + DBG (DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } - DBG (DBG_info, "%s: average = %d\n", __FUNCTION__, avg[channel]); + DBG (DBG_info, "%s: average = %d\n", __func__, avg[channel]); return avg[channel]; } @@ -3786,7 +3786,7 @@ gl843_init_regs_for_warmup (Genesys_Device * dev, if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -3875,7 +3875,7 @@ gl843_boot (Genesys_Device * dev, SANE_Bool cold) { RIE (sanei_genesys_read_register (dev, 0x00, &val)); DBG (DBG_info, - "%s: reported version for genesys chip is 0x%02x\n", __FUNCTION__, + "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } @@ -3998,7 +3998,7 @@ SANE_Status gl843_move_to_ta (Genesys_Device * dev) status = gl843_feed (dev, feed); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to move to XPA calibration area\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to move to XPA calibration area\n", __func__); return status; } @@ -4357,16 +4357,16 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* 16 bit words, 2 words per color, 3 color channels */ offset=(strpixel-startx)*2*2*3; length=(endpixel-strpixel)*2*2*3; - DBG (DBG_info, "%s: STRPIXEL=%d, ENDPIXEL=%d, startx=%d\n", __FUNCTION__, strpixel, endpixel, startx); + DBG (DBG_info, "%s: STRPIXEL=%d, ENDPIXEL=%d, startx=%d\n", __func__, strpixel, endpixel, startx); } /* compute and allocate size for final data */ final_size = ((length+251) / 252) * 256; - DBG (DBG_io, "%s: final shading size=%04x (length=%d)\n", __FUNCTION__, final_size, length); + DBG (DBG_io, "%s: final shading size=%04x (length=%d)\n", __func__, final_size, length); final_data = (uint8_t *) malloc (final_size); if(final_data==NULL) { - DBG (DBG_error, "%s: failed to allocate memory for shading data\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate memory for shading data\n", __func__); return SANE_STATUS_NO_MEM; } memset(final_data,0x00,final_size); @@ -4390,7 +4390,7 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = sanei_genesys_set_buffer_address (dev, 0); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set buffer address: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus (status)); free(final_data); return status; } @@ -4398,7 +4398,7 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, final_data, count); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading table: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to send shading table: %s\n", __func__, sane_strstatus (status)); } free(final_data); @@ -4446,6 +4446,7 @@ static Genesys_Command_Set gl843_cmd_set = { gl843_led_calibration, gl843_slow_back_home, + NULL, sanei_genesys_bulk_write_register, gl843_bulk_write_data, diff --git a/backend/genesys_gl843.h b/backend/genesys_gl843.h index f31f0ee..4be46cc 100644 --- a/backend/genesys_gl843.h +++ b/backend/genesys_gl843.h @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2013 Stéphane Voltz This file is part of the SANE package. @@ -73,8 +73,8 @@ SANE_Status gl843_xpa_motor_off (Genesys_Device * dev); SANE_Status gl843_move_to_ta (Genesys_Device * dev); #endif -#define DBGSTART DBG (DBG_proc, "%s start\n", __FUNCTION__); -#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __FUNCTION__); +#define DBGSTART DBG (DBG_proc, "%s start\n", __func__); +#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __func__); #define REG01 0x01 #define REG01_CISSET 0x80 diff --git a/backend/genesys_gl846.c b/backend/genesys_gl846.c index 3991693..0716c17 100644 --- a/backend/genesys_gl846.c +++ b/backend/genesys_gl846.c @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2012-2013 Stéphane Voltz + Copyright (C) 2012-2013 Stéphane Voltz This file is part of the SANE package. @@ -117,7 +117,7 @@ gl846_bulk_read_data (Genesys_Device * dev, uint8_t addr, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "%s failed while writing command: %s\n", - __FUNCTION__, sane_strstatus (status)); + __func__, sane_strstatus (status)); return status; } @@ -162,7 +162,7 @@ gl846_bulk_read_data (Genesys_Device * dev, uint8_t addr, DBG (DBG_io2, "gl846_bulk_read_data: %lu bytes of data read\n", (u_long) done); } - DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __FUNCTION__, + DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, (u_long) size, (u_long) (target - size)); target -= size; @@ -269,7 +269,7 @@ gl846_get_step_multiplier (Genesys_Register_Set * regs) value = (r->value & 0x0f)>>1; value = 1 << value; } - DBG (DBG_io, "%s: step multiplier is %d\n", __FUNCTION__, value); + DBG (DBG_io, "%s: step multiplier is %d\n", __func__, value); return value; } @@ -317,7 +317,7 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi) /* default fallback */ if(idx<0) { - DBG (DBG_warn,"%s: using default sensor profile\n",__FUNCTION__); + DBG (DBG_warn,"%s: using default sensor profile\n",__func__); idx=0; } @@ -577,13 +577,13 @@ gl846_send_slope_table (Genesys_Device * dev, int table_nr, int i; char msg[10000]; - DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __FUNCTION__, + DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __func__, table_nr, steps); /* sanity check */ if(table_nr<0 || table_nr>4) { - DBG (DBG_error, "%s: invalid table number %d!\n", __FUNCTION__, table_nr); + DBG (DBG_error, "%s: invalid table number %d!\n", __func__, table_nr); return SANE_STATUS_INVAL; } @@ -601,7 +601,7 @@ gl846_send_slope_table (Genesys_Device * dev, int table_nr, { sprintf (msg+strlen(msg), "%d", slope_table[i]); } - DBG (DBG_io, "%s: %s\n", __FUNCTION__, msg); + DBG (DBG_io, "%s: %s\n", __func__, msg); } /* slope table addresses are fixed */ @@ -610,7 +610,7 @@ gl846_send_slope_table (Genesys_Device * dev, int table_nr, { DBG (DBG_error, "%s: write to AHB failed writing slope table %d (%s)\n", - __FUNCTION__, table_nr, sane_strstatus (status)); + __func__, table_nr, sane_strstatus (status)); } free (table); @@ -641,7 +641,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set) if (set == AFE_INIT) { - DBG (DBG_proc, "%s(): setting DAC %u\n", __FUNCTION__, dev->model->dac_type); + DBG (DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); /* sets to default values */ sanei_genesys_init_fe (dev); @@ -652,7 +652,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to write reg0: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus (status)); return status; } @@ -660,7 +660,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to write reg1: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to write reg1: %s\n", __func__, sane_strstatus (status)); return status; } @@ -672,7 +672,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to write gain %d: %s\n", __FUNCTION__, i, + "%s: failed to write gain %d: %s\n", __func__, i, sane_strstatus (status)); return status; } @@ -684,7 +684,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to write offset %d: %s\n", __FUNCTION__, i, + "%s: failed to write offset %d: %s\n", __func__, i, sane_strstatus (status)); return status; } @@ -781,10 +781,10 @@ gl846_init_motor_regs_scan (Genesys_Device * dev, { use_fast_fed=1; } - DBG (DBG_io, "%s: use_fast_fed=%d\n", __FUNCTION__, use_fast_fed); + DBG (DBG_io, "%s: use_fast_fed=%d\n", __func__, use_fast_fed); sanei_genesys_set_triple(reg, REG_LINCNT, scan_lines); - DBG (DBG_io, "%s: lincnt=%d\n", __FUNCTION__, scan_lines); + DBG (DBG_io, "%s: lincnt=%d\n", __func__, scan_lines); /* compute register 02 value */ r = sanei_genesys_get_address (reg, REG02); @@ -863,8 +863,8 @@ gl846_init_motor_regs_scan (Genesys_Device * dev, if (flags & MOTOR_FLAG_FEED) dist *=2; } - DBG (DBG_io2, "%s: scan steps=%d\n", __FUNCTION__, scan_steps); - DBG (DBG_io2, "%s: acceleration distance=%d\n", __FUNCTION__, dist); + DBG (DBG_io2, "%s: scan steps=%d\n", __func__, scan_steps); + DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* check for overflow */ if(distvalue & REG0C_CCDLMT)+1; @@ -1024,13 +1024,13 @@ gl846_init_optical_regs_scan (Genesys_Device * dev, /* resolution is divided according to CKSEL */ r = sanei_genesys_get_address (reg, REG18); cksel= (r->value & REG18_CKSEL)+1; - DBG (DBG_io2, "%s: cksel=%d\n", __FUNCTION__, cksel); + DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel); /* to manage high resolution device while keeping good * low resolution scanning speed, we make hardware dpi vary */ dpihw=sanei_genesys_compute_dpihw(dev, used_res * cksel); factor=dev->sensor.optical_res/dpihw; - DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __FUNCTION__, dpihw, factor); + DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); /* sensor parameters */ sensor=get_sensor_profile(dev->model->ccd_type, dpihw); @@ -1215,20 +1215,20 @@ gl846_init_optical_regs_scan (Genesys_Device * dev, dev->line_interp = 0; sanei_genesys_set_double(reg,REG_DPISET,dpiset); - DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset); + DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); sanei_genesys_set_double(reg,REG_STRPIXEL,startx); sanei_genesys_set_double(reg,REG_ENDPIXEL,endx); - DBG (DBG_io2, "%s: startx=%d\n", __FUNCTION__, startx); - DBG (DBG_io2, "%s: endx =%d\n", __FUNCTION__, endx); + DBG (DBG_io2, "%s: startx=%d\n", __func__, startx); + DBG (DBG_io2, "%s: endx =%d\n", __func__, endx); - DBG (DBG_io2, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); - DBG (DBG_io2, "%s: pixels =%d\n", __FUNCTION__, pixels); - DBG (DBG_io2, "%s: depth =%d\n", __FUNCTION__, depth); - DBG (DBG_io2, "%s: dev->bpl =%lu\n", __FUNCTION__, (unsigned long)dev->bpl); - DBG (DBG_io2, "%s: dev->len =%lu\n", __FUNCTION__, (unsigned long)dev->len); - DBG (DBG_io2, "%s: dev->dist =%lu\n", __FUNCTION__, (unsigned long)dev->dist); - DBG (DBG_io2, "%s: dev->segnb =%lu\n", __FUNCTION__, (unsigned long)dev->segnb); + DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels); + DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); + DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); + DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl); + DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); + DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); + DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb); words_per_line *= channels; dev->wpl = words_per_line; @@ -1241,10 +1241,10 @@ gl846_init_optical_regs_scan (Genesys_Device * dev, /* MAXWD is expressed in 4 words unit */ sanei_genesys_set_triple(reg, REG_MAXWD, (words_per_line >> 2)); - DBG (DBG_io2, "%s: words_per_line used=%d\n", __FUNCTION__, words_per_line); + DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); sanei_genesys_set_double(reg, REG_LPERIOD, exposure_time); - DBG (DBG_io2, "%s: exposure_time used=%d\n", __FUNCTION__, exposure_time); + DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); r = sanei_genesys_get_address (reg, 0x34); r->value = dev->sensor.dummy_pixel; @@ -1645,7 +1645,7 @@ gl846_calculate_current_setup (Genesys_Device * dev) slope_dpi = slope_dpi * (1 + dummy); exposure_time = gl846_compute_exposure (dev, used_res); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time); + DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /* max_shift */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); @@ -1761,7 +1761,7 @@ gl846_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -1770,7 +1770,7 @@ gl846_stop_action (Genesys_Device * dev) /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __FUNCTION__); + DBG (DBG_info, "%s: already stopped\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -1783,7 +1783,7 @@ gl846_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to write register 01: %s\n", __FUNCTION__, + "%s: failed to write register 01: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1801,7 +1801,7 @@ gl846_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -1962,7 +1962,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* is sensor at home? */ if (val & HOMESNR) { - DBG (DBG_info, "%s: already at home, completed\n", __FUNCTION__); + DBG (DBG_info, "%s: already at home, completed\n", __func__); dev->scanhead_position_in_steps = 0; DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -2257,7 +2257,7 @@ gl846_feed (Genesys_Device * dev, unsigned int steps) uint8_t val; DBGSTART; - DBG (DBG_io, "%s: steps=%d\n", __FUNCTION__, steps); + DBG (DBG_io, "%s: steps=%d\n", __func__, steps); /* prepare local registers */ memcpy (local_reg, dev->reg, GENESYS_GL846_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2306,7 +2306,7 @@ gl846_feed (Genesys_Device * dev, unsigned int steps) status = gl846_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); gl846_stop_action (dev); /* restore original registers */ @@ -2348,8 +2348,8 @@ gl846_init_regs_for_shading (Genesys_Device * dev) if(dev->calib_resolution==4800) dev->calib_lines *= 2; dev->calib_pixels = (dev->sensor.sensor_pixels*dev->calib_resolution)/dev->sensor.optical_res; - DBG (DBG_io, "%s: calib_lines = %d\n", __FUNCTION__, (unsigned int)dev->calib_lines); - DBG (DBG_io, "%s: calib_pixels = %d\n", __FUNCTION__, (unsigned int)dev->calib_pixels); + DBG (DBG_io, "%s: calib_lines = %d\n", __func__, (unsigned int)dev->calib_lines); + DBG (DBG_io, "%s: calib_pixels = %d\n", __func__, (unsigned int)dev->calib_pixels); /* this is aworkaround insufficent distance for slope * motor acceleration TODO special motor slope for shading */ @@ -2377,14 +2377,14 @@ gl846_init_regs_for_shading (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL846_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2452,7 +2452,7 @@ gl846_init_regs_for_scan (Genesys_Device * dev) move += dev->settings.tl_y; move = (move * move_dpi) / MM_PER_INCH; move -= dev->scanhead_position_in_steps; - DBG (DBG_info, "%s: move=%f steps\n",__FUNCTION__, move); + DBG (DBG_info, "%s: move=%f steps\n",__func__, move); /* fast move to scan area */ /* we don't move fast the whole distance since it would involve @@ -2464,14 +2464,14 @@ gl846_init_regs_for_scan (Genesys_Device * dev) status = gl846_feed (dev, move-500); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to move to scan area\n",__FUNCTION__); + DBG (DBG_error, "%s: failed to move to scan area\n",__func__); return status; } move=500; } DBG (DBG_info, "gl846_init_regs_for_scan: move=%f steps\n", move); - DBG (DBG_info, "%s: move=%f steps\n", __FUNCTION__, move); + DBG (DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = SANE_UNFIX (dev->model->x_offset); @@ -2526,7 +2526,7 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t val,*buffer,*ptr,*src; DBGSTART; - DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__FUNCTION__,size); + DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__func__,size); /* shading data is plit in 3 (up to 5 with IR) areas write(0x10014000,0x00000dd8) @@ -2543,10 +2543,10 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* compute deletion factor */ sanei_genesys_get_double(dev->reg,REG_DPISET,&tempo); dpiset=tempo; - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n",__FUNCTION__,strpixel,endpixel,endpixel-strpixel,dpiset); + DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n",__func__,strpixel,endpixel,endpixel-strpixel,dpiset); dpihw=sanei_genesys_compute_dpihw(dev,dpiset); factor=dpihw/dpiset; - DBG( DBG_io2, "%s: factor=%d\n",__FUNCTION__,factor); + DBG( DBG_io2, "%s: factor=%d\n",__func__,factor); if(DBG_LEVEL>=DBG_data) { @@ -2571,7 +2571,7 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* allocate temporary buffer */ buffer=(uint8_t *)malloc(pixels); memset(buffer,0,pixels); - DBG( DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n",__FUNCTION__,pixels,pixels); + DBG( DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n",__func__,pixels,pixels); /* base addr of data has been written in reg D0-D4 in 4K word, so AHB address * is 8192*reg value */ @@ -2649,7 +2649,7 @@ gl846_led_calibration (Genesys_Device * dev) { RIE(gl846_feed (dev, move)); } - DBG (DBG_io, "%s: move=%f steps\n", __FUNCTION__, move); + DBG (DBG_io, "%s: move=%f steps\n", __func__, move); /* offset calibration is always done in color mode */ channels = 3; @@ -2679,7 +2679,7 @@ gl846_led_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2816,7 +2816,7 @@ gl846_init_gpio (Genesys_Device * dev) } if(gpios[idx].sensor_id==0) { - DBG (DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __FUNCTION__, dev->model->ccd_type); + DBG (DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __func__, dev->model->ccd_type); return SANE_STATUS_INVAL; } @@ -2857,7 +2857,7 @@ gl846_init_memory_layout (Genesys_Device * dev) } if(layouts[idx].model==NULL) { - DBG(DBG_error, "%s: failed to find memory layout for model %s!\n", __FUNCTION__, dev->model->name); + DBG(DBG_error, "%s: failed to find memory layout for model %s!\n", __func__, dev->model->name); return SANE_STATUS_INVAL; } @@ -2915,7 +2915,7 @@ gl846_boot (Genesys_Device * dev, SANE_Bool cold) if (val & REG40_CHKVER) { RIE (sanei_genesys_read_register (dev, 0x00, &val)); - DBG (DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __FUNCTION__, val); + DBG (DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ @@ -3680,6 +3680,7 @@ static Genesys_Command_Set gl846_cmd_set = { gl846_led_calibration, gl846_slow_back_home, + NULL, sanei_genesys_bulk_write_register, NULL, diff --git a/backend/genesys_gl846.h b/backend/genesys_gl846.h index d57f149..e1dc711 100644 --- a/backend/genesys_gl846.h +++ b/backend/genesys_gl846.h @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2012-2013 Stéphane Voltz + Copyright (C) 2012-2013 Stéphane Voltz This file is part of the SANE package. diff --git a/backend/genesys_gl847.c b/backend/genesys_gl847.c index 7c4d19c..a3b35a2 100644 --- a/backend/genesys_gl847.c +++ b/backend/genesys_gl847.c @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2013 Stéphane Voltz This file is part of the SANE package. @@ -113,7 +113,7 @@ gl847_bulk_read_data (Genesys_Device * dev, uint8_t addr, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "%s failed while writing command: %s\n", - __FUNCTION__, sane_strstatus (status)); + __func__, sane_strstatus (status)); return status; } @@ -158,7 +158,7 @@ gl847_bulk_read_data (Genesys_Device * dev, uint8_t addr, DBG (DBG_io2, "gl847_bulk_read_data: %lu bytes of data read\n", (u_long) done); } - DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __FUNCTION__, + DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, (u_long) size, (u_long) (target - size)); target -= size; @@ -265,7 +265,7 @@ gl847_get_step_multiplier (Genesys_Register_Set * regs) value = (r->value & 0x0f)>>1; value = 1 << value; } - DBG (DBG_io, "%s: step multiplier is %d\n", __FUNCTION__, value); + DBG (DBG_io, "%s: step multiplier is %d\n", __func__, value); return value; } @@ -313,7 +313,7 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi) /* default fallback */ if(idx<0) { - DBG (DBG_warn,"%s: using default sensor profile\n",__FUNCTION__); + DBG (DBG_warn,"%s: using default sensor profile\n",__func__); idx=0; } @@ -600,13 +600,13 @@ gl847_send_slope_table (Genesys_Device * dev, int table_nr, int i; char msg[10000]; - DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __FUNCTION__, + DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __func__, table_nr, steps); /* sanity check */ if(table_nr<0 || table_nr>4) { - DBG (DBG_error, "%s: invalid table number %d!\n", __FUNCTION__, table_nr); + DBG (DBG_error, "%s: invalid table number %d!\n", __func__, table_nr); return SANE_STATUS_INVAL; } @@ -624,7 +624,7 @@ gl847_send_slope_table (Genesys_Device * dev, int table_nr, { sprintf (msg+strlen(msg), "%d", slope_table[i]); } - DBG (DBG_io, "%s: %s\n", __FUNCTION__, msg); + DBG (DBG_io, "%s: %s\n", __func__, msg); } /* slope table addresses are fixed */ @@ -634,7 +634,7 @@ gl847_send_slope_table (Genesys_Device * dev, int table_nr, { DBG (DBG_error, "%s: write to AHB failed writing slope table %d (%s)\n", - __FUNCTION__, table_nr, sane_strstatus (status)); + __func__, table_nr, sane_strstatus (status)); } free (table); @@ -824,10 +824,10 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, { use_fast_fed=1; } - DBG (DBG_io, "%s: use_fast_fed=%d\n", __FUNCTION__, use_fast_fed); + DBG (DBG_io, "%s: use_fast_fed=%d\n", __func__, use_fast_fed); sanei_genesys_set_triple(reg, REG_LINCNT, scan_lines); - DBG (DBG_io, "%s: lincnt=%d\n", __FUNCTION__, scan_lines); + DBG (DBG_io, "%s: lincnt=%d\n", __func__, scan_lines); /* compute register 02 value */ r = sanei_genesys_get_address (reg, REG02); @@ -906,8 +906,8 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, if (flags & MOTOR_FLAG_FEED) dist *=2; } - DBG (DBG_io2, "%s: scan steps=%d\n", __FUNCTION__, scan_steps); - DBG (DBG_io2, "%s: acceleration distance=%d\n", __FUNCTION__, dist); + DBG (DBG_io2, "%s: scan steps=%d\n", __func__, scan_steps); + DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* check for overflow */ if(distvalue & REG0C_CCDLMT)+1; @@ -1048,13 +1048,13 @@ gl847_init_optical_regs_scan (Genesys_Device * dev, /* resolution is divided according to CKSEL */ r = sanei_genesys_get_address (reg, REG18); cksel= (r->value & REG18_CKSEL)+1; - DBG (DBG_io2, "%s: cksel=%d\n", __FUNCTION__, cksel); + DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel); /* to manage high resolution device while keeping good * low resolution scanning speed, we make hardware dpi vary */ dpihw=sanei_genesys_compute_dpihw(dev, used_res * cksel); factor=dev->sensor.optical_res/dpihw; - DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __FUNCTION__, dpihw, factor); + DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); /* sensor parameters */ sensor=get_sensor_profile(dev->model->ccd_type, dpihw); @@ -1239,20 +1239,20 @@ gl847_init_optical_regs_scan (Genesys_Device * dev, dev->line_interp = 0; sanei_genesys_set_double(reg,REG_DPISET,dpiset); - DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset); + DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); sanei_genesys_set_double(reg,REG_STRPIXEL,startx); sanei_genesys_set_double(reg,REG_ENDPIXEL,endx); - DBG (DBG_io2, "%s: startx=%d\n", __FUNCTION__, startx); - DBG (DBG_io2, "%s: endx =%d\n", __FUNCTION__, endx); + DBG (DBG_io2, "%s: startx=%d\n", __func__, startx); + DBG (DBG_io2, "%s: endx =%d\n", __func__, endx); - DBG (DBG_io2, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); - DBG (DBG_io2, "%s: pixels =%d\n", __FUNCTION__, pixels); - DBG (DBG_io2, "%s: depth =%d\n", __FUNCTION__, depth); - DBG (DBG_io2, "%s: dev->bpl =%lu\n", __FUNCTION__, (unsigned long)dev->bpl); - DBG (DBG_io2, "%s: dev->len =%lu\n", __FUNCTION__, (unsigned long)dev->len); - DBG (DBG_io2, "%s: dev->dist =%lu\n", __FUNCTION__, (unsigned long)dev->dist); - DBG (DBG_io2, "%s: dev->segnb =%lu\n", __FUNCTION__, (unsigned long)dev->segnb); + DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels); + DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); + DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); + DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl); + DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); + DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); + DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb); words_per_line *= channels; dev->wpl = words_per_line; @@ -1265,10 +1265,10 @@ gl847_init_optical_regs_scan (Genesys_Device * dev, /* MAXWD is expressed in 4 words unit */ sanei_genesys_set_triple(reg, REG_MAXWD, (words_per_line >> 2)); - DBG (DBG_io2, "%s: words_per_line used=%d\n", __FUNCTION__, words_per_line); + DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); sanei_genesys_set_double(reg, REG_LPERIOD, exposure_time); - DBG (DBG_io2, "%s: exposure_time used=%d\n", __FUNCTION__, exposure_time); + DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); r = sanei_genesys_get_address (reg, 0x34); r->value = dev->sensor.dummy_pixel; @@ -1669,7 +1669,7 @@ gl847_calculate_current_setup (Genesys_Device * dev) slope_dpi = slope_dpi * (1 + dummy); exposure_time = gl847_compute_exposure (dev, used_res); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time); + DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /* max_shift */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); @@ -1785,7 +1785,7 @@ gl847_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -1794,7 +1794,7 @@ gl847_stop_action (Genesys_Device * dev) /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __FUNCTION__); + DBG (DBG_info, "%s: already stopped\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -1807,7 +1807,7 @@ gl847_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to write register 01: %s\n", __FUNCTION__, + "%s: failed to write register 01: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1825,7 +1825,7 @@ gl847_stop_action (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); DBGCOMPLETED; return status; @@ -1929,10 +1929,50 @@ gl847_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, return status; } -/* Moves the slider to the home (top) postion slowly */ -#ifndef UNIT_TESTING -static -#endif +/** rewind scan + * Move back by the same amount of distance than previous scan. + * @param dev device to rewind + * @returns SANE_STATUS_GOOD on success + */ +GENESYS_STATIC +SANE_Status gl847_rewind(Genesys_Device * dev) +{ + SANE_Status status; + uint8_t byte; + + DBGSTART; + + /* set motor reverse */ + RIE (sanei_genesys_read_register (dev, 0x02, &byte)); + byte |= 0x04; + RIE (sanei_genesys_write_register(dev, 0x02, byte)); + + /* and start scan, then wait completion */ + RIE (gl847_begin_scan (dev, dev->reg, SANE_TRUE)); + do + { + usleep(100*1000); + RIE (sanei_genesys_read_register (dev, REG40, &byte)); + } + while(byte & REG40_MOTMFLG); + RIE (gl847_end_scan (dev, dev->reg, SANE_TRUE)); + + /* restore direction */ + RIE (sanei_genesys_read_register (dev, 0x02, &byte)); + byte &= 0xfb; + RIE (sanei_genesys_write_register(dev, 0x02, byte)); + + DBGCOMPLETED; + return SANE_STATUS_GOOD; +} + +/** Park head + * Moves the slider to the home (top) position slowly + * @param dev device to park + * @param wait_until_home true to make the function waiting for head + * to be home before returning, if fals returne immediately + * @returns SANE_STATUS_GOO on success */ +GENESYS_STATIC SANE_Status gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) { @@ -1982,7 +2022,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* is sensor at home? */ if (val & HOMESNR) { - DBG (DBG_info, "%s: already at home, completed\n", __FUNCTION__); + DBG (DBG_info, "%s: already at home, completed\n", __func__); dev->scanhead_position_in_steps = 0; DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -2279,7 +2319,7 @@ gl847_feed (Genesys_Device * dev, unsigned int steps) uint8_t val; DBGSTART; - DBG (DBG_io, "%s: steps=%d\n", __FUNCTION__, steps); + DBG (DBG_io, "%s: steps=%d\n", __func__, steps); /* prepare local registers */ memcpy (local_reg, dev->reg, GENESYS_GL847_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2328,7 +2368,7 @@ gl847_feed (Genesys_Device * dev, unsigned int steps) status = gl847_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); gl847_stop_action (dev); /* restore original registers */ @@ -2370,8 +2410,8 @@ gl847_init_regs_for_shading (Genesys_Device * dev) if(dev->calib_resolution==4800) dev->calib_lines *= 2; dev->calib_pixels = (dev->sensor.sensor_pixels*dev->calib_resolution)/dev->sensor.optical_res; - DBG (DBG_io, "%s: calib_lines = %d\n", __FUNCTION__, (int)dev->calib_lines); - DBG (DBG_io, "%s: calib_pixels = %d\n", __FUNCTION__, (int)dev->calib_pixels); + DBG (DBG_io, "%s: calib_lines = %d\n", __func__, (int)dev->calib_lines); + DBG (DBG_io, "%s: calib_pixels = %d\n", __func__, (int)dev->calib_pixels); /* this is aworkaround insufficent distance for slope * motor acceleration TODO special motor slope for shading */ @@ -2399,14 +2439,14 @@ gl847_init_regs_for_shading (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL847_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2474,7 +2514,7 @@ gl847_init_regs_for_scan (Genesys_Device * dev) move += dev->settings.tl_y; move = (move * move_dpi) / MM_PER_INCH; move -= dev->scanhead_position_in_steps; - DBG (DBG_info, "%s: move=%f steps\n",__FUNCTION__, move); + DBG (DBG_info, "%s: move=%f steps\n",__func__, move); /* fast move to scan area */ /* we don't move fast the whole distance since it would involve @@ -2486,14 +2526,14 @@ gl847_init_regs_for_scan (Genesys_Device * dev) status = gl847_feed (dev, move-500); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to move to scan area\n",__FUNCTION__); + DBG (DBG_error, "%s: failed to move to scan area\n",__func__); return status; } move=500; } DBG (DBG_info, "gl124_init_regs_for_scan: move=%f steps\n", move); - DBG (DBG_info, "%s: move=%f steps\n", __FUNCTION__, move); + DBG (DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = SANE_UNFIX (dev->model->x_offset); @@ -2548,7 +2588,7 @@ gl847_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t val,*buffer,*ptr,*src; DBGSTART; - DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__FUNCTION__,size); + DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__func__,size); /* shading data is plit in 3 (up to 5 with IR) areas write(0x10014000,0x00000dd8) @@ -2565,10 +2605,10 @@ gl847_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* compute deletion factor */ sanei_genesys_get_double(dev->reg,REG_DPISET,&tempo); dpiset=tempo; - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n",__FUNCTION__,strpixel,endpixel,endpixel-strpixel,dpiset); + DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n",__func__,strpixel,endpixel,endpixel-strpixel,dpiset); dpihw=sanei_genesys_compute_dpihw(dev,dpiset); factor=dpihw/dpiset; - DBG( DBG_io2, "%s: factor=%d\n",__FUNCTION__,factor); + DBG( DBG_io2, "%s: factor=%d\n",__func__,factor); if(DBG_LEVEL>=DBG_data) { @@ -2593,7 +2633,7 @@ gl847_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* allocate temporary buffer */ buffer=(uint8_t *)malloc(pixels); memset(buffer,0,pixels); - DBG( DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n",__FUNCTION__,pixels,pixels); + DBG( DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n",__func__,pixels,pixels); /* base addr of data has been written in reg D0-D4 in 4K word, so AHB address * is 8192*reg value */ @@ -2670,7 +2710,7 @@ gl847_led_calibration (Genesys_Device * dev) { RIE(gl847_feed (dev, move)); } - DBG (DBG_io, "%s: move=%f steps\n", __FUNCTION__, move); + DBG (DBG_io, "%s: move=%f steps\n", __func__, move); /* offset calibration is always done in color mode */ channels = 3; @@ -2700,7 +2740,7 @@ gl847_led_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __FUNCTION__, sane_strstatus (status)); + DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2837,7 +2877,7 @@ gl847_init_gpio (Genesys_Device * dev) } if(gpios[idx].sensor_id==0) { - DBG (DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __FUNCTION__, dev->model->ccd_type); + DBG (DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __func__, dev->model->ccd_type); return SANE_STATUS_INVAL; } @@ -2972,7 +3012,7 @@ gl847_boot (Genesys_Device * dev, SANE_Bool cold) if (val & REG40_CHKVER) { RIE (sanei_genesys_read_register (dev, 0x00, &val)); - DBG (DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __FUNCTION__, val); + DBG (DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ @@ -3753,6 +3793,7 @@ static Genesys_Command_Set gl847_cmd_set = { gl847_led_calibration, gl847_slow_back_home, + gl847_rewind, sanei_genesys_bulk_write_register, NULL, diff --git a/backend/genesys_gl847.h b/backend/genesys_gl847.h index 9901e23..1da2065 100644 --- a/backend/genesys_gl847.h +++ b/backend/genesys_gl847.h @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2013 Stéphane Voltz This file is part of the SANE package. diff --git a/backend/genesys_low.c b/backend/genesys_low.c index f28b72c..4cbd75d 100644 --- a/backend/genesys_low.c +++ b/backend/genesys_low.c @@ -1,6 +1,6 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2010-2013 Stéphane Voltz + Copyright (C) 2010-2013 Stéphane Voltz This file is part of the SANE package. @@ -516,7 +516,7 @@ sanei_genesys_set_buffer_address (Genesys_Device * dev, uint32_t addr) return status; } -/** read data for analog frontend +/**@brief read data from analog frontend (AFE) * @param dev device owning the AFE * @param addr register address to read * @param data placeholder for the result @@ -558,7 +558,13 @@ sanei_genesys_fe_read_data (Genesys_Device * dev, uint8_t addr, return status; } -/* Write data for analog frontend */ +/*@brief write data to analog frontend + * writes data to analog frontend to set it up accordingly + * to the sensor settings (exposure, timings, color, bit depth, ...) + * @param dev devie owning the AFE to write to + * @param addr AFE rister address + * @param data value to write to AFE register + **/ SANE_Status sanei_genesys_fe_write_data (Genesys_Device * dev, uint8_t addr, uint16_t data) @@ -737,7 +743,7 @@ sanei_genesys_read_valid_words (Genesys_Device * dev, unsigned int *words) *words += ((value & 0x0f) * 256 * 256); } - DBG (DBG_proc, "%s: %d words\n", __FUNCTION__, *words); + DBG (DBG_proc, "%s: %d words\n", __func__, *words); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -1098,7 +1104,7 @@ sanei_genesys_bulk_write_register (Genesys_Device * dev, } } - DBG (DBG_io, "%s: wrote %lu registers\n", __FUNCTION__, (u_long) elems); + DBG (DBG_io, "%s: wrote %lu registers\n", __func__, (u_long) elems); return status; } @@ -1136,8 +1142,8 @@ sanei_genesys_write_ahb (SANE_Int dn, int usb_mode, uint32_t addr, uint32_t size { sprintf (msg+strlen(msg), " 0x%02x", outdata[i]); } - DBG (DBG_io, "%s: write(0x%08x,0x%08x)\n", __FUNCTION__, addr,size); - DBG (DBG_io, "%s: %s\n", __FUNCTION__, msg); + DBG (DBG_io, "%s: write(0x%08x,0x%08x)\n", __func__, addr,size); + DBG (DBG_io, "%s: %s\n", __func__, msg); } /* no effective write if fake USB */ @@ -1315,7 +1321,7 @@ sanei_genesys_send_gamma_table (Genesys_Device * dev) { free (gamma); DBG (DBG_error, - "%s: write to AHB failed writing table %d (%s)\n", __FUNCTION__, + "%s: write to AHB failed writing table %d (%s)\n", __func__, i, sane_strstatus (status)); } } @@ -1352,12 +1358,12 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_IN, REQUEST_REGISTER, VALUE_GET_REGISTER, 0x00, 1, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: request register failed %s\n", __FUNCTION__, + DBG (DBG_error, "%s: request register failed %s\n", __func__, sane_strstatus (status)); return status; } - DBG (DBG_io2, "%s: value=0x%02x\n", __FUNCTION__, val); - DBG (DBG_info, "%s: device is %s\n", __FUNCTION__, (val & 0x08) ? "USB 1.0" : "USB2.0"); + DBG (DBG_io2, "%s: value=0x%02x\n", __func__, val); + DBG (DBG_info, "%s: device is %s\n", __func__, (val & 0x08) ? "USB 1.0" : "USB2.0"); if (val & 0x08) { dev->usb_mode = 1; @@ -1377,7 +1383,7 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) if (dev->sensor.gamma_table[i] == NULL) { DBG (DBG_error, "%s: could not allocate memory for gamma table %d\n", - __FUNCTION__, i); + __func__, i); return SANE_STATUS_NO_MEM; } sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i], @@ -1397,13 +1403,13 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) { cold = SANE_FALSE; } - DBG (DBG_info, "%s: device is %s\n", __FUNCTION__, cold ? "cold" : "warm"); + DBG (DBG_info, "%s: device is %s\n", __func__, cold ? "cold" : "warm"); /* don't do anything if backend is initialized and hardware hasn't been * replug */ if (dev->already_initialized && !cold) { - DBG (DBG_info, "%s: already initialized, nothing to do\n", __FUNCTION__); + DBG (DBG_info, "%s: already initialized, nothing to do\n", __func__); return SANE_STATUS_GOOD; } @@ -1459,7 +1465,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1468,7 +1474,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1477,7 +1483,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev) if(val & HOMESNR) { DBG (DBG_info, - "%s: already at home\n", __FUNCTION__); + "%s: already at home\n", __func__); return status; } @@ -1491,7 +1497,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __FUNCTION__, + "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1506,7 +1512,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev) /* if after the timeout, head is still not parked, error out */ if(loop >= max && !(val & HOMESNR) && status == SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to reach park position %ds\n", __FUNCTION__, max/10); + DBG (DBG_error, "%s: failed to reach park position %ds\n", __func__, max/10); return SANE_STATUS_IO_ERROR; } @@ -1597,7 +1603,7 @@ Motor_Profile *sanei_genesys_get_motor_profile(Motor_Profile *motors, int motor_ /* default fallback */ if(idx<0) { - DBG (DBG_warn,"%s: using default motor profile\n",__FUNCTION__); + DBG (DBG_warn,"%s: using default motor profile\n",__func__); idx=0; } @@ -1654,7 +1660,7 @@ Motor_Profile *profile; /* required speed */ target=((exposure * dpi) / base_dpi)>>step_type; - DBG (DBG_io2, "%s: exposure=%d, dpi=%d, target=%d\n", __FUNCTION__, exposure, dpi, target); + DBG (DBG_io2, "%s: exposure=%d, dpi=%d, target=%d\n", __func__, exposure, dpi, target); /* fill result with target speed */ for(i=0;itable[i]==0 && DBG_LEVEL >= DBG_warn && current>target) { - DBG (DBG_warn,"%s: short slope table, failed to reach %d. target too low ?\n",__FUNCTION__,target); + DBG (DBG_warn,"%s: short slope table, failed to reach %d. target too low ?\n",__func__,target); } if(i<3 && DBG_LEVEL >= DBG_warn) { - DBG (DBG_warn,"%s: short slope table, failed to reach %d. target too high ?\n",__FUNCTION__,target); + DBG (DBG_warn,"%s: short slope table, failed to reach %d. target too high ?\n",__func__,target); } /* align on factor */ @@ -1791,20 +1797,20 @@ sanei_genesys_is_compatible_calibration (Genesys_Device * dev, if(dev->model->cmd_set->calculate_current_setup==NULL) { - DBG (DBG_proc, "%s: no calculate_setup, non compatible cache\n", __FUNCTION__); + DBG (DBG_proc, "%s: no calculate_setup, non compatible cache\n", __func__); return SANE_STATUS_UNSUPPORTED; } status = dev->model->cmd_set->calculate_current_setup (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to calculate current setup: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to calculate current setup: %s\n", __func__, sane_strstatus (status)); return status; } dev->current_setup.scan_method = dev->settings.scan_method; - DBG (DBG_proc, "%s: checking\n", __FUNCTION__); + DBG (DBG_proc, "%s: checking\n", __func__); /* a calibration cache is compatible if color mode and x dpi match the user * requested scan. In the case of CIS scanners, dpi isn't a criteria */ @@ -1822,22 +1828,22 @@ sanei_genesys_is_compatible_calibration (Genesys_Device * dev, resolution=sanei_genesys_compute_dpihw(dev,dev->settings.xres); compatible = (resolution == ((int) sanei_genesys_compute_dpihw(dev,cache->used_setup.xres))); } - DBG (DBG_io, "%s: after resolution check current compatible=%d\n", __FUNCTION__, compatible); + DBG (DBG_io, "%s: after resolution check current compatible=%d\n", __func__, compatible); if (dev->current_setup.half_ccd != cache->used_setup.half_ccd) { - DBG (DBG_io, "%s: half_ccd=%d, used=%d\n", __FUNCTION__, + DBG (DBG_io, "%s: half_ccd=%d, used=%d\n", __func__, dev->current_setup.half_ccd, cache->used_setup.half_ccd); compatible = 0; } if (dev->current_setup.scan_method != cache->used_setup.scan_method) { - DBG (DBG_io, "%s: current method=%d, used=%d\n", __FUNCTION__, + DBG (DBG_io, "%s: current method=%d, used=%d\n", __func__, dev->current_setup.scan_method, cache->used_setup.scan_method); compatible = 0; } if (!compatible) { - DBG (DBG_proc, "%s: completed, non compatible cache\n", __FUNCTION__); + DBG (DBG_proc, "%s: completed, non compatible cache\n", __func__); return SANE_STATUS_UNSUPPORTED; } @@ -1851,7 +1857,7 @@ sanei_genesys_is_compatible_calibration (Genesys_Device * dev, && (dev->model->is_sheetfed == SANE_FALSE) && (dev->settings.scan_method == SCAN_METHOD_FLATBED)) { - DBG (DBG_proc, "%s: expired entry, non compatible cache\n", __FUNCTION__); + DBG (DBG_proc, "%s: expired entry, non compatible cache\n", __func__); return SANE_STATUS_UNSUPPORTED; } } diff --git a/backend/genesys_low.h b/backend/genesys_low.h index b5a0a8f..56627b4 100644 --- a/backend/genesys_low.h +++ b/backend/genesys_low.h @@ -3,7 +3,7 @@ Copyright (C) 2003 Oliver Rauch Copyright (C) 2003, 2004 Henning Meier-Geinitz Copyright (C) 2004, 2005 Gerhard Jaeger - Copyright (C) 2004-2013 Stéphane Voltz + Copyright (C) 2004-2013 Stéphane Voltz Copyright (C) 2005-2009 Pierre Willenbrock Copyright (C) 2006 Laurent Charpentier Parts of the structs have been taken from the gt68xx backend by @@ -104,7 +104,7 @@ do { status = function; \ if (status != SANE_STATUS_GOOD) \ { \ - DBG(DBG_error, "%s: %s\n", __FUNCTION__, sane_strstatus (status)); \ + DBG(DBG_error, "%s: %s\n", __func__, sane_strstatus (status)); \ return status; \ } \ } while (SANE_FALSE) @@ -114,7 +114,7 @@ if (status != SANE_STATUS_GOOD) \ { \ free(mem); \ - DBG(DBG_error, "%s: %s\n", __FUNCTION__, sane_strstatus (status)); \ + DBG(DBG_error, "%s: %s\n", __func__, sane_strstatus (status)); \ return status; \ } \ } while (SANE_FALSE) @@ -129,8 +129,8 @@ } \ } while (SANE_FALSE) -#define DBGSTART DBG (DBG_proc, "%s start\n", __FUNCTION__); -#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __FUNCTION__); +#define DBGSTART DBG (DBG_proc, "%s start\n", __func__); +#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __func__); #define FREE_IFNOT_NULL(x) if(x!=NULL) { free(x); x=NULL;} @@ -352,6 +352,7 @@ Genesys_Color_Order; #define DAC_IMG101 18 #define DAC_PLUSTEK3800 19 #define DAC_CANONLIDE80 20 +#define DAC_CANONLIDE120 21 #define CCD_UMAX 0 #define CCD_ST12 1 /* SONY ILX548: 5340 Pixel ??? */ @@ -410,6 +411,7 @@ Genesys_Color_Order; #define GPO_IMG101 22 #define GPO_PLUSTEK3800 23 #define GPO_CANONLIDE80 24 +#define GPO_CANONLIDE120 25 #define MOTOR_UMAX 0 #define MOTOR_5345 1 @@ -435,6 +437,7 @@ Genesys_Color_Order; #define MOTOR_PLUSTEK3800 22 #define MOTOR_CANONLIDE210 23 #define MOTOR_CANONLIDE80 24 +#define MOTOR_CANONLIDE120 25 /* Forward typedefs */ @@ -506,8 +509,8 @@ typedef struct Genesys_Command_Set SANE_Status (*coarse_gain_calibration) (Genesys_Device * dev, int dpi); SANE_Status (*led_calibration) (Genesys_Device * dev); - SANE_Status (*slow_back_home) (Genesys_Device * dev, - SANE_Bool wait_until_home); + SANE_Status (*slow_back_home) (Genesys_Device * dev, SANE_Bool wait_until_home); + SANE_Status (*rewind) (Genesys_Device * dev); SANE_Status (*bulk_write_register) (Genesys_Device * dev, Genesys_Register_Set * reg, diff --git a/backend/gphoto2.c b/backend/gphoto2.c index 7b297c4..c8af306 100644 --- a/backend/gphoto2.c +++ b/backend/gphoto2.c @@ -353,14 +353,23 @@ static const SANE_Device *devlist[] = { * debug_func - called for gphoto2 debugging output (if enabled) */ static void +#ifdef GPLOGFUNC_NO_VARGS +debug_func (GPLogLevel level, const char *domain, const char *message, + void __sane_unused__ * data) +#else debug_func (GPLogLevel level, const char *domain, const char *format, - va_list args, void UNUSEDARG * data) + va_list args, void __sane_unused__ * data) +#endif { if (level == GP_LOG_ERROR) DBG (0, "%s(ERROR): ", domain); else DBG (0, "%s(%i): ", domain, level); +#ifdef GPLOGFUNC_NO_VARGS + DBG (0, "%s", message); +#else sanei_debug_msg (0, DBG_LEVEL, STRINGIFY (BACKEND_NAME), format, args); +#endif DBG (0, "\n"); } @@ -650,7 +659,7 @@ change_res (SANE_Byte res) * is present, and initialize gphoto2 */ SANE_Status -sane_init (SANE_Int * version_code, SANE_Auth_Callback UNUSEDARG authorize) +sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { SANE_Int n, entries; SANE_Char f[] = "sane_init"; @@ -940,7 +949,7 @@ sane_exit (void) */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool - UNUSEDARG local_only) + __sane_unused__ local_only) { DBG (127, "sane_get_devices called\n"); @@ -1314,7 +1323,7 @@ my_source_mgr; typedef my_source_mgr *my_src_ptr; METHODDEF (void) -jpeg_init_source (j_decompress_ptr UNUSEDARG cinfo) +jpeg_init_source (j_decompress_ptr __sane_unused__ cinfo) { /* nothing to do */ } @@ -1361,7 +1370,7 @@ METHODDEF (void) jpeg_skip_input_data (j_decompress_ptr cinfo, long num_bytes) } METHODDEF (void) -jpeg_term_source (j_decompress_ptr UNUSEDARG cinfo) +jpeg_term_source (j_decompress_ptr __sane_unused__ cinfo) { /* no work necessary here */ } @@ -1476,7 +1485,7 @@ sane_start (SANE_Handle handle) * sane_read() - From SANE API */ SANE_Status -sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data, +sane_read (SANE_Handle __sane_unused__ handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { if (Cam_data.scanning == SANE_FALSE) @@ -1530,7 +1539,7 @@ sane_read (SANE_Handle UNUSEDARG handle, SANE_Byte * data, * sane_cancel() - From SANE API */ void -sane_cancel (SANE_Handle UNUSEDARG handle) +sane_cancel (SANE_Handle __sane_unused__ handle) { if (Cam_data.scanning) { @@ -1544,8 +1553,8 @@ sane_cancel (SANE_Handle UNUSEDARG handle) * sane_set_io_mode() - From SANE API */ SANE_Status -sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool - UNUSEDARG non_blocking) +sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool + __sane_unused__ non_blocking) { /* sane_set_io_mode() is only valid during a scan */ if (Cam_data.scanning) @@ -1570,7 +1579,7 @@ sane_set_io_mode (SANE_Handle UNUSEDARG handle, SANE_Bool * sane_get_select_fd() - From SANE API */ SANE_Status -sane_get_select_fd (SANE_Handle UNUSEDARG handle, SANE_Int UNUSEDARG * fd) +sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { return SANE_STATUS_UNSUPPORTED; } @@ -1738,13 +1747,13 @@ read_dir (SANE_String dir, SANE_Bool read_files) { if (gp_list_free (dir_list) < 0) { - DBG (0, "%s: errror: gp_list_free failed\n", f); + DBG (0, "%s: error: gp_list_free failed\n", f); } dir_list = NULL; } if (gp_list_new (&dir_list) < 0) { - DBG (0, "%s: errror: gp_list_new failed\n", f); + DBG (0, "%s: error: gp_list_new failed\n", f); } if (read_files) @@ -1783,7 +1792,7 @@ read_info (SANE_String_Const fname) * set_res - set picture size depending on resolution settings */ static void -set_res (SANE_Int UNUSEDARG lowres) +set_res (SANE_Int __sane_unused__ lowres) { if (gphoto2_opt_thumbnails) { @@ -1943,7 +1952,6 @@ converter_scan_complete (void) static SANE_Status converter_init (SANE_Handle handle) { - SANE_Int row_stride; struct jpeg_error_mgr jerr; my_src_ptr src; @@ -1982,8 +1990,6 @@ exit(1); dest_mgr = sanei_jpeg_jinit_write_ppm (&cinfo); (void) jpeg_start_decompress (&cinfo); - row_stride = cinfo.output_width * cinfo.output_components; - parms.bytes_per_line = cinfo.output_width * 3; /* 3 colors */ parms.pixels_per_line = cinfo.output_width; parms.lines = cinfo.output_height; diff --git a/backend/gphoto2.h b/backend/gphoto2.h index 4ef953b..60591cf 100644 --- a/backend/gphoto2.h +++ b/backend/gphoto2.h @@ -155,12 +155,6 @@ struct cam_dirent long size; }; -#ifdef __GNUC__ -#define UNUSEDARG __attribute__ ((unused)) -#else -#define UNUSEDARG -#endif - struct cam_dirlist { SANE_Char name[48]; diff --git a/backend/gt68xx.c b/backend/gt68xx.c index ea71d91..13efe91 100644 --- a/backend/gt68xx.c +++ b/backend/gt68xx.c @@ -2346,7 +2346,7 @@ sane_cancel (SANE_Handle handle) else { DBG (4, "sane_cancel: scan has not been initiated yet, " - "or it is allready aborted\n"); + "or it is already aborted\n"); } DBG (5, "sane_cancel: exit\n"); diff --git a/backend/gt68xx_low.h b/backend/gt68xx_low.h index 68cd7c5..0743230 100644 --- a/backend/gt68xx_low.h +++ b/backend/gt68xx_low.h @@ -73,9 +73,6 @@ /* return if an error occured while the function was called */ #ifdef MAX_DEBUG -# ifndef __FUNCTION__ -# define __FUNCTION__ "somewhere" -# endif # define RIE(function) \ do \ @@ -83,7 +80,7 @@ status = function; \ if (status != SANE_STATUS_GOOD) \ { \ - DBG (7, "%s: %s: %s\n", __FUNCTION__, STRINGIFY(function), \ + DBG (7, "%s: %s: %s\n", __func__, STRINGIFY(function), \ sane_strstatus (status)); \ return status; \ } \ diff --git a/backend/hp-accessor.c b/backend/hp-accessor.c index b1acd7c..8b79ad4 100644 --- a/backend/hp-accessor.c +++ b/backend/hp-accessor.c @@ -687,20 +687,20 @@ sanei_hp_accessor_vector_new (HpData data, unsigned length, unsigned depth) } static unsigned short -_gamma_vector_unscale (HpAccessorVector UNUSEDARG this, SANE_Fixed fval) +_gamma_vector_unscale (HpAccessorVector __sane_unused__ this, SANE_Fixed fval) { unsigned short unscaled = fval / SANE_FIX(1.0); if (unscaled > 255) unscaled = 255; - unscaled = 255 - unscaled; /* Dont know why. But this is how it works */ + unscaled = 255 - unscaled; /* Don't know why. But this is how it works. */ return unscaled; } static SANE_Fixed -_gamma_vector_scale (HpAccessorVector UNUSEDARG this, unsigned short val) +_gamma_vector_scale (HpAccessorVector __sane_unused__ this, unsigned short val) { SANE_Fixed scaled; - val = 255-val; /* Dont know why. But this is how it works */ + val = 255-val; /* Don't know why. But this is how it works. */ scaled = val * SANE_FIX(1.0); return scaled; diff --git a/backend/hp-device.c b/backend/hp-device.c index 2b96ad6..6a50f84 100644 --- a/backend/hp-device.c +++ b/backend/hp-device.c @@ -249,7 +249,6 @@ sanei_hp_device_probe_model (enum hp_device_compat_e *compat, HpScsi scsi, }; int i; char buf[8]; - size_t len; SANE_Status status; static char *last_device = NULL; static enum hp_device_compat_e last_compat; @@ -279,7 +278,6 @@ sanei_hp_device_probe_model (enum hp_device_compat_e *compat, HpScsi scsi, { DBG(1,"probing %s\n",probes[i].model); - len = sizeof(buf); if (!FAILED( status = sanei_hp_scl_upload(scsi, probes[i].cmd, buf, sizeof(buf)) )) { diff --git a/backend/hp-handle.c b/backend/hp-handle.c index d9be2d5..ec8adbc 100644 --- a/backend/hp-handle.c +++ b/backend/hp-handle.c @@ -192,7 +192,7 @@ hp_handle_startReader (HpHandle this, HpScsi scsi) this->pipe_write_fd = -1; } - if (this->reader_pid == -1) /* Creating child failed ? Clean up pipe */ + if (!sanei_thread_is_valid (this->reader_pid)) { if ( !this->child_forked ) { diff --git a/backend/hp-option.c b/backend/hp-option.c index 10bcb3e..ba799b7 100644 --- a/backend/hp-option.c +++ b/backend/hp-option.c @@ -114,7 +114,7 @@ static SANE_Status hp_probe_parameter_support_table (enum hp_device_compat_e #define HP_EOL -9999 -/* Dont need requiries for commands that are probed */ +/* Don't need requiries for commands that are probed */ #define HP_PROBE_SCL_COMMAND 1 /* Scale factor for vectors (gtk seems not to like vectors/curves @@ -298,15 +298,15 @@ sanei_hp_choice_isEnabled (HpChoice this, HpOptSet optset, HpData data, } static hp_bool_t -_cenable_incolor (HpChoice UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_cenable_incolor (HpChoice __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { return sanei_hp_optset_scanmode(optset, data) == HP_SCANMODE_COLOR; } static hp_bool_t -_cenable_notcolor (HpChoice UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_cenable_notcolor (HpChoice __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { return sanei_hp_optset_scanmode(optset, data) != HP_SCANMODE_COLOR; } @@ -744,7 +744,7 @@ _set_size (HpOption opt, HpData data, SANE_Int size) /* #ifdef HP_EXPERIMENTAL */ static SANE_Status -_probe_int (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, HpData data) +_probe_int (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { HpScl scl = this->descriptor->scl_command; int minval, maxval; @@ -770,7 +770,7 @@ _probe_int (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, HpData data) /* #endif */ static SANE_Status -_probe_int_brightness (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_int_brightness (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { HpScl scl = this->descriptor->scl_command; @@ -811,7 +811,7 @@ _probe_int_brightness (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, } static SANE_Status -_probe_resolution (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_resolution (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { int minval, maxval, min2, max2; @@ -868,7 +868,7 @@ _probe_resolution (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, } static SANE_Status -_probe_bool (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_bool (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { HpScl scl = this->descriptor->scl_command; @@ -891,7 +891,7 @@ _probe_bool (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, static SANE_Status -_probe_change_doc (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_change_doc (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) {SANE_Status status; @@ -927,7 +927,7 @@ _probe_change_doc (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, * _probe_change_doc(), to hide the unnecessary "Unload" button on * non-ADF OfficeJets. */ static SANE_Status -_probe_unload (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_unload (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) {SANE_Status status; @@ -959,7 +959,7 @@ _probe_unload (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, } static SANE_Status -_probe_calibrate (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_calibrate (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { int val = 0; /* Always false */ @@ -1144,7 +1144,7 @@ _probe_choice (_HpOption this, HpScsi scsi, HpOptSet optset, HpData data) } static SANE_Status -_probe_each_choice (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_each_choice (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { HpScl scl = this->descriptor->scl_command; @@ -1194,7 +1194,7 @@ _probe_each_choice (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, /* pseudo probe for exposure times in Photosmart */ static SANE_Status -_probe_ps_exposure_time (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_ps_exposure_time (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { int minval = 0, maxval = 9, val = 0; @@ -1229,7 +1229,7 @@ _probe_ps_exposure_time (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, /* probe scan type (normal, adf, xpa) */ static SANE_Status -_probe_scan_type (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_scan_type (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { int val; @@ -1300,7 +1300,7 @@ _probe_scan_type (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, } static SANE_Status -_probe_mirror_horiz (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_mirror_horiz (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { HpScl scl = this->descriptor->scl_command; @@ -1345,7 +1345,7 @@ _probe_mirror_horiz (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, } static SANE_Status -_probe_mirror_vert (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_mirror_vert (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { int minval = HP_MIRROR_VERT_OFF, @@ -1390,7 +1390,7 @@ _probe_mirror_vert (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, static SANE_Status _probe_front_button(_HpOption this, HpScsi scsi, - HpOptSet UNUSEDARG optset, HpData data) + HpOptSet __sane_unused__ optset, HpData data) { int val = 0; @@ -1501,7 +1501,7 @@ _probe_download_type (HpScl scl, HpScsi scsi) } static SANE_Status -_probe_custom_gamma (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_custom_gamma (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { HpScl scl = this->descriptor->scl_command; @@ -1694,8 +1694,8 @@ _probe_matrix (_HpOption this, HpScsi scsi, HpOptSet optset, HpData data) } static SANE_Status -_probe_num_options (_HpOption this, HpScsi UNUSEDARG scsi, - HpOptSet UNUSEDARG optset, HpData data) +_probe_num_options (_HpOption this, HpScsi __sane_unused__ scsi, + HpOptSet __sane_unused__ optset, HpData data) { /* If we dont have an accessor, get one */ if (!this->data_acsr) @@ -1708,7 +1708,7 @@ _probe_num_options (_HpOption this, HpScsi UNUSEDARG scsi, } static SANE_Status -_probe_devpix (_HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_probe_devpix (_HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { HpScl scl = this->descriptor->scl_command; @@ -2102,7 +2102,7 @@ _program_matrix (HpOption this, HpScsi scsi, HpOptSet optset, HpData data) } static SANE_Status -_program_resolution (HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_program_resolution (HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { @@ -2326,7 +2326,7 @@ _program_media (HpOption this, HpScsi scsi, HpOptSet optset, HpData data) static SANE_Status _program_unload_after_scan (HpOption this, HpScsi scsi, - HpOptSet UNUSEDARG optset, HpData data) + HpOptSet __sane_unused__ optset, HpData data) { HpDeviceInfo *info; info = sanei_hp_device_info_get ( sanei_hp_scsi_devicename (scsi) ); @@ -2340,8 +2340,8 @@ _program_unload_after_scan (HpOption this, HpScsi scsi, } static SANE_Status -_program_lamp_off (HpOption UNUSEDARG this, HpScsi scsi, - HpOptSet UNUSEDARG optset, HpData UNUSEDARG data) +_program_lamp_off (HpOption __sane_unused__ this, HpScsi scsi, + HpOptSet __sane_unused__ optset, HpData __sane_unused__ data) { DBG(3,"program_lamp_off: shut off lamp\n"); @@ -2436,8 +2436,8 @@ _program_scan_type (HpOption this, HpScsi scsi, HpOptSet optset, HpData data) } static SANE_Status -_program_change_doc (HpOption UNUSEDARG this, HpScsi scsi, - HpOptSet UNUSEDARG optset, HpData UNUSEDARG data) +_program_change_doc (HpOption __sane_unused__ this, HpScsi scsi, + HpOptSet __sane_unused__ optset, HpData __sane_unused__ data) { int istat; @@ -2492,8 +2492,8 @@ _program_unload (HpOption this, HpScsi scsi, HpOptSet optset, HpData data) } static SANE_Status -_program_calibrate (HpOption UNUSEDARG this, HpScsi scsi, - HpOptSet UNUSEDARG optset, HpData UNUSEDARG data) +_program_calibrate (HpOption __sane_unused__ this, HpScsi scsi, + HpOptSet __sane_unused__ optset, HpData __sane_unused__ data) { struct passwd *pw; SANE_Status status = SANE_STATUS_GOOD; @@ -2525,7 +2525,7 @@ _program_calibrate (HpOption UNUSEDARG this, HpScsi scsi, * speed for higher exposure times */ static SANE_Status _program_ps_exposure_time (HpOption this, HpScsi scsi, - HpOptSet UNUSEDARG optset, HpData data) + HpOptSet __sane_unused__ optset, HpData data) { SANE_Status status = SANE_STATUS_GOOD; size_t calib_size = 0; @@ -2650,7 +2650,7 @@ _program_scanmode (HpOption this, HpScsi scsi, HpOptSet optset, HpData data) } static SANE_Status -_program_mirror_horiz (HpOption this, HpScsi scsi, HpOptSet UNUSEDARG optset, +_program_mirror_horiz (HpOption this, HpScsi scsi, HpOptSet __sane_unused__ optset, HpData data) { int sec_dir, mirror = hp_option_getint(this, data); @@ -2695,8 +2695,8 @@ _enable_rgb_maps (HpOption this, HpOptSet optset, HpData data, #endif static hp_bool_t -_enable_mono_map (HpOption UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_enable_mono_map (HpOption __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { HpOption cgam = hp_optset_get(optset, CUSTOM_GAMMA); @@ -2706,8 +2706,8 @@ _enable_mono_map (HpOption UNUSEDARG this, HpOptSet optset, HpData data, } static hp_bool_t -_enable_rgb_matrix (HpOption UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_enable_rgb_matrix (HpOption __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { HpOption type = hp_optset_get(optset, MATRIX_TYPE); @@ -2746,8 +2746,8 @@ _enable_brightness (HpOption this, HpOptSet optset, HpData data, } static hp_bool_t -_enable_autoback (HpOption UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_enable_autoback (HpOption __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { return sanei_hp_optset_scanmode(optset, data) == HP_SCANMODE_LINEART; } @@ -2788,15 +2788,15 @@ _enable_custom_gamma (HpOption this, HpOptSet optset, HpData data, } static hp_bool_t -_enable_halftone (HpOption UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_enable_halftone (HpOption __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { return sanei_hp_optset_scanmode(optset, data) == HP_SCANMODE_HALFTONE; } static hp_bool_t -_enable_halftonevec (HpOption UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_enable_halftonevec (HpOption __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { if (sanei_hp_optset_scanmode(optset, data) == HP_SCANMODE_HALFTONE) { @@ -2808,8 +2808,8 @@ _enable_halftonevec (HpOption UNUSEDARG this, HpOptSet optset, HpData data, } static hp_bool_t -_enable_data_width (HpOption UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_enable_data_width (HpOption __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) {enum hp_scanmode_e mode; mode = sanei_hp_optset_scanmode (optset, data); @@ -2817,7 +2817,7 @@ _enable_data_width (HpOption UNUSEDARG this, HpOptSet optset, HpData data, } static hp_bool_t -_enable_out8 (HpOption UNUSEDARG this, HpOptSet optset, HpData data, +_enable_out8 (HpOption __sane_unused__ this, HpOptSet optset, HpData data, const HpDeviceInfo *info) { if (hp_optset_isEnabled (optset, data, SANE_NAME_BIT_DEPTH, info)) @@ -2829,8 +2829,8 @@ _enable_out8 (HpOption UNUSEDARG this, HpOptSet optset, HpData data, } static hp_bool_t -_enable_calibrate (HpOption UNUSEDARG this, HpOptSet optset, HpData data, - const HpDeviceInfo UNUSEDARG *info) +_enable_calibrate (HpOption __sane_unused__ this, HpOptSet optset, HpData data, + const HpDeviceInfo __sane_unused__ *info) { HpOption media = hp_optset_get(optset, MEDIA); diff --git a/backend/hp-scl.c b/backend/hp-scl.c index e58508b..f1813c7 100644 --- a/backend/hp-scl.c +++ b/backend/hp-scl.c @@ -339,7 +339,7 @@ hp_nonscsi_write (HpScsi this, hp_byte_t *data, size_t len, HpConnect connect) static SANE_Status hp_nonscsi_read (HpScsi this, hp_byte_t *data, size_t *len, HpConnect connect, - int UNUSEDARG isResponse) + int __sane_unused__ isResponse) {int n = -1; static int retries = -1; @@ -905,7 +905,7 @@ hp_scsi_scl(HpScsi this, HpScl scl, int val) RETURN_IF_FAIL( hp_scsi_need(this, 10) ); - /* Dont try to optimize SCL-commands like using *a1b0c5T */ + /* Don't try to optimize SCL-commands like using *a1b0c5T */ /* Some scanners have problems with it (e.g. HP Photosmart Photoscanner */ /* with window position/extent, resolution) */ count = sprintf((char *)this->bufp, "\033*%c%d%c", group, val, param); @@ -1011,7 +1011,7 @@ hp_scsi_read (HpScsi this, void * dest, size_t *len, int isResponse) static int signal_caught = 0; -static RETSIGTYPE +static void signal_catcher (int sig) { DBG(1,"signal_catcher(sig=%d): old signal_caught=%d\n",sig,signal_caught); @@ -1338,13 +1338,11 @@ static SANE_Status process_data (PROCDATA_HANDLE *ph, unsigned char *read_ptr, int nread) {int bytes_left; - HpProcessData *procdata; if (nread <= 0) return SANE_STATUS_GOOD; if (ph == NULL) return SANE_STATUS_INVAL; - procdata = &(ph->procdata); if ( ph->tmp_buf_len > 0 ) /* Something left ? */ { bytes_left = ph->tmp_buf_size - ph->tmp_buf_len; @@ -2083,7 +2081,7 @@ hp_scl_strerror (int errnum) case 1024: return "ADF Paper Jam"; case 1025: return "Home Position Missing"; case 1026: return "Paper Not Loaded"; - default: return "??Unkown Error??"; + default: return "??Unknown Error??"; } } diff --git a/backend/hp.c b/backend/hp.c index c85e40c..f00b82d 100644 --- a/backend/hp.c +++ b/backend/hp.c @@ -468,13 +468,11 @@ static void hp_device_info_remove (void) { HpDeviceInfoList next, infolistelement = global.infolist; - HpDeviceInfo *info; if (!global.is_up) return; while (infolistelement) { - info = &(infolistelement->info); next = infolistelement->next; sanei_hp_free (infolistelement); infolistelement = next; @@ -811,7 +809,7 @@ hp_update_devlist (void) */ SANE_Status -sane_init (SANE_Int *version_code, SANE_Auth_Callback UNUSEDARG authorize) +sane_init (SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize) {SANE_Status status; DBG_INIT(); @@ -839,7 +837,7 @@ sane_exit (void) SANE_Status sane_get_devices (const SANE_Device ***device_list, - SANE_Bool UNUSEDARG local_only) + SANE_Bool __sane_unused__ local_only) { DBG(3, "sane_get_devices called\n"); diff --git a/backend/hp.h b/backend/hp.h index b86ee04..42b3be5 100644 --- a/backend/hp.h +++ b/backend/hp.h @@ -53,12 +53,6 @@ #define DEBUG_NOT_STATIC #include "../include/sane/sanei_debug.h" -#ifdef __GNUC__ -#define UNUSEDARG __attribute__ ((unused)) -#else -#define UNUSEDARG -#endif - /* FIXME: these should be options? */ #undef ENABLE_7x12_TONEMAPS #define ENABLE_16x16_DITHERS diff --git a/backend/hp3500.c b/backend/hp3500.c index 48a8035..26fe071 100644 --- a/backend/hp3500.c +++ b/backend/hp3500.c @@ -84,6 +84,7 @@ #include #include #include +#include #include #include @@ -145,6 +146,7 @@ enum hp3500_option OPT_MODE, OPT_BRIGHTNESS, OPT_CONTRAST, + OPT_GAMMA, NUM_OPTIONS }; @@ -189,6 +191,8 @@ struct hp3500_data int brightness; int contrast; + double gamma; + SANE_Option_Descriptor opt[NUM_OPTIONS]; SANE_Device sane; }; @@ -218,6 +222,8 @@ static const SANE_Range range_brightness = { 0, 255, 0 }; static const SANE_Range range_contrast = { 0, 255, 0 }; +static const SANE_Range range_gamma = + { SANE_FIX (0.2), SANE_FIX(4.0), SANE_FIX(0.01) }; #define HP3500_COLOR_SCAN 0 @@ -233,6 +239,7 @@ static int reader_process (void *); static void calculateDerivedValues (struct hp3500_data *scanner); static void do_reset (struct hp3500_data *scanner); static void do_cancel (struct hp3500_data *scanner); +static size_t max_string_size(char const **); /* * used by sane_get_devices @@ -382,6 +389,7 @@ sane_open (SANE_String_Const name, SANE_Handle * handle) scanner->mode = 0; scanner->brightness = 128; scanner->contrast = 64; + scanner->gamma = 2.2; calculateDerivedValues (scanner); return SANE_STATUS_GOOD; @@ -536,6 +544,10 @@ sane_control_option (SANE_Handle handle, SANE_Int option, *(SANE_Word *) val = scanner->contrast; return SANE_STATUS_GOOD; + case OPT_GAMMA: + *(SANE_Word *) val = SANE_FIX(scanner->gamma); + return SANE_STATUS_GOOD; + case OPT_BRIGHTNESS: *(SANE_Word *) val = scanner->brightness; return SANE_STATUS_GOOD; @@ -649,6 +661,10 @@ sane_control_option (SANE_Handle handle, SANE_Int option, case OPT_CONTRAST: scanner->contrast = *(SANE_Word *) val; return SANE_STATUS_GOOD; + + case OPT_GAMMA: + scanner->gamma = SANE_UNFIX(*(SANE_Word *) val); + return SANE_STATUS_GOOD; } /* switch */ } /* else */ return SANE_STATUS_INVAL; @@ -703,7 +719,7 @@ sane_start (SANE_Handle handle) scanner->reader_pid = sanei_thread_begin (reader_process, scanner); time (&scanner->last_scan); - if (scanner->reader_pid == -1) + if (!sanei_thread_is_valid (scanner->reader_pid)) { DBG (MSG_ERR, "cannot fork reader process.\n"); DBG (MSG_ERR, "%s", strerror (errno)); @@ -952,7 +968,7 @@ attachScanner (const char *devicename) dev->devicename = strdup (devicename); dev->sfd = -1; dev->last_scan = 0; - dev->reader_pid = -1; + dev->reader_pid = (SANE_Pid) -1; dev->pipe_r = dev->pipe_w = -1; dev->sane.name = dev->devicename; @@ -1064,8 +1080,9 @@ init_options (struct hp3500_data *scanner) opt->title = SANE_TITLE_SCAN_MODE; opt->desc = SANE_DESC_SCAN_MODE; opt->type = SANE_TYPE_STRING; + opt->size = max_string_size(scan_mode_list); opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; - opt->constraint.string_list = scan_mode_list; + opt->constraint.string_list = (SANE_String_Const *) scan_mode_list; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_BRIGHTNESS; @@ -1086,6 +1103,16 @@ init_options (struct hp3500_data *scanner) opt->constraint.range = &range_contrast; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; + opt = scanner->opt + OPT_GAMMA; + opt->name = SANE_NAME_ANALOG_GAMMA; + opt->title = SANE_TITLE_ANALOG_GAMMA; + opt->desc = SANE_DESC_ANALOG_GAMMA; + opt->type = SANE_TYPE_FIXED; + opt->unit = SANE_UNIT_NONE; + opt->constraint_type = SANE_CONSTRAINT_RANGE; + opt->constraint.range = &range_gamma; + opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; + return SANE_STATUS_GOOD; } @@ -1098,7 +1125,7 @@ do_reset (struct hp3500_data *scanner) static void do_cancel (struct hp3500_data *scanner) { - if (scanner->reader_pid != -1) + if (sanei_thread_is_valid (scanner->reader_pid)) { if (sanei_thread_kill (scanner->reader_pid) == 0) @@ -1749,14 +1776,14 @@ rt_set_basic_calibration (unsigned char *regs, int greengain, int blueoffset1, int blueoffset2, int bluegain) { - regs[0x05] = redoffset1; - regs[0x02] = redoffset2; + regs[0x02] = redoffset1; + regs[0x05] = redoffset2; regs[0x08] = redgain; - regs[0x06] = greenoffset1; - regs[0x03] = greenoffset2; + regs[0x03] = greenoffset1; + regs[0x06] = greenoffset2; regs[0x09] = greengain; - regs[0x07] = blueoffset1; - regs[0x04] = blueoffset2; + regs[0x04] = blueoffset1; + regs[0x07] = blueoffset2; regs[0x0a] = bluegain; return 0; } @@ -1765,13 +1792,36 @@ static int rt_set_calibration_addresses (unsigned char *regs, unsigned redaddr, unsigned greenaddr, - unsigned blueaddr, unsigned endaddr) + unsigned blueaddr, + unsigned endaddr, + unsigned width) { + unsigned endpage = (endaddr + 31) / 32; + unsigned scanline_pages = ((width + 1) * 3 + 31) / 32; + + /* Red, green and blue detailed calibration addresses */ + regs[0x84] = redaddr; regs[0x8e] = (regs[0x8e] & 0x0f) | ((redaddr >> 4) & 0xf0); rt_set_value_lsbfirst (regs, 0x85, 2, greenaddr); rt_set_value_lsbfirst (regs, 0x87, 2, blueaddr); - rt_set_value_lsbfirst (regs, 0x89, 2, (endaddr + 31) / 32); + + /* I don't know what the next three are used for, but each buffer commencing + * at 0x80 and 0x82 needs to hold a full scan line. + */ + + rt_set_value_lsbfirst (regs, 0x80, 2, endpage); + rt_set_value_lsbfirst (regs, 0x82, 2, endpage + scanline_pages); + rt_set_value_lsbfirst (regs, 0x89, 2, endpage + scanline_pages * 2); + + /* I don't know what this is, but it seems to be a number of pages that can hold + * 16 complete scan lines, but not calculated as an offset from any other page + */ + + rt_set_value_lsbfirst (regs, 0x51, 2, (48 * (width + 1) + 31) / 32); + + /* I don't know what this is either, but this is what the Windows driver does */ + rt_set_value_lsbfirst (regs, 0x8f, 2, 0x1c00); return 0; } @@ -1797,6 +1847,13 @@ rt_set_data_feed_on (unsigned char *regs) return 0; } +static int +rt_set_data_feed_off (unsigned char *regs) +{ + regs[0xb2] |= 0x04; + return 0; +} + static int rt_enable_ccd (unsigned char *regs, int enable) { @@ -2245,10 +2302,14 @@ rt_nvram_read (int block, int location, unsigned char *data, int bytes) return 0; } +/* This is what we want as the initial registers, not what they + * are at power on time. In particular 13 bytes at 0x10 are + * different, and the byte at 0x94 is different. + */ static unsigned char initial_regs[] = { /* 0x00 */ 0xf5, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08 */ 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, - /* 0x10 */ 0xe1, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfc, + /* 0x10 */ 0x81, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x20 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x19, @@ -2264,7 +2325,7 @@ static unsigned char initial_regs[] = { /* 0x78 */ 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */ 0x0f, 0x02, 0x4b, 0x02, 0x00, 0xec, 0x19, 0xd8, /* 0x88 */ 0x2d, 0x87, 0x02, 0xff, 0x3f, 0x78, 0x60, 0x00, - /* 0x90 */ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x90 */ 0x1c, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, /* 0x98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0 */ 0x00, 0x00, 0x00, 0x0c, 0x27, 0x64, 0x00, 0x00, /* 0xa8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -2363,14 +2424,14 @@ static struct resolution_parameters resparms[] = { /* My values - all work */ /*res r39 rC3 rC6 freq cph0s rgo gbo intra mmcm d3 tg stepsz */ {1200, 3, 6, 4, 2, 1, 22, 22, 4, 2, 1, RT_NORMAL_TG, 0x157b}, - {600, 15, 6, 4, 1, 0, 9, 10, 0, 2, 1, RT_NORMAL_TG, 0x055e}, + {600, 15, 6, 4, 1, 1, 9, 10, 0, 2, 1, RT_NORMAL_TG, 0x055e}, {400, 3, 1, 4, 1, 1, 6, 6, 1, 2, 1, RT_NORMAL_TG, 0x157b}, - {300, 15, 3, 4, 1, 0, 5, 4, 0, 2, 1, RT_NORMAL_TG, 0x02af}, - {200, 7, 1, 4, 1, 0, 3, 3, 0, 2, 1, RT_NORMAL_TG, 0x055e}, - {150, 15, 3, 1, 1, 0, 2, 2, 0, 2, 1, RT_NORMAL_TG, 0x02af}, - {100, 3, 1, 3, 1, 0, 1, 1, 0, 2, 1, RT_NORMAL_TG, 0x0abd}, - {75, 15, 3, 3, 1, 0, 1, 1, 0, 2, 1, RT_NORMAL_TG, 0x02af}, - {50, 15, 1, 1, 1, 0, 0, 0, 0, 2, 1, RT_NORMAL_TG, 0x055e}, + {300, 15, 3, 4, 1, 1, 5, 4, 0, 2, 1, RT_NORMAL_TG, 0x02af}, + {200, 7, 1, 4, 1, 1, 3, 3, 0, 2, 1, RT_NORMAL_TG, 0x055e}, + {150, 15, 3, 1, 1, 1, 2, 2, 0, 2, 1, RT_NORMAL_TG, 0x02af}, + {100, 3, 1, 3, 1, 1, 1, 1, 0, 2, 1, RT_NORMAL_TG, 0x0abd}, + {75, 15, 3, 3, 1, 1, 1, 1, 0, 2, 1, RT_NORMAL_TG, 0x02af}, + {50, 15, 1, 1, 1, 1, 0, 0, 0, 2, 1, RT_NORMAL_TG, 0x055e}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; @@ -2597,6 +2658,90 @@ constrain (int val, int min, int max) return val; } +#if 0 +static void +sram_dump_byte(FILE *fp, + unsigned char const *left, + unsigned leftstart, + unsigned leftlimit, + unsigned char const *right, + unsigned rightstart, + unsigned rightlimit, + unsigned idx) +{ + unsigned ridx = rightstart + idx; + unsigned lidx = leftstart + idx; + + putc(' ', fp); + if (rightstart < rightlimit && leftstart < leftlimit && left[lidx] != right[ridx]) + fputs("", fp); + if (leftstart < leftlimit) + fprintf(fp, "%02x", left[lidx]); + else + fputs(" ", fp); + if (rightstart < rightlimit && leftstart < leftlimit && left[lidx] != right[ridx]) + fputs("", fp); +} + +static void +dump_sram_to_file(char const *fname, + unsigned char const *expected, + unsigned end_calibration_offset) +{ + FILE *fp = fopen(fname, "w"); + rt_set_sram_page(0); + + if (fp) + { + unsigned char buf[1024]; + unsigned loc = 0; + + fprintf(fp, "
\n");
+      while (loc < end_calibration_offset)
+        {
+          unsigned byte = 0;
+
+          rt_read_sram(1024, buf);
+
+          while (byte < 1024)
+            {
+              unsigned idx = 0;
+
+              fprintf(fp, "%06x:", loc);
+              do
+                {
+		  sram_dump_byte(fp, buf, byte, 1024, expected, loc, end_calibration_offset, idx);
+                } while (++idx & 0x7);
+              fprintf(fp, " -");
+              do
+                {
+		  sram_dump_byte(fp, buf, byte, 1024, expected, loc, end_calibration_offset, idx);
+                } while (++idx & 0x7);
+
+              idx = 0;
+              fputs("     ", fp);
+
+              do
+                {
+                  sram_dump_byte(fp, expected, loc, end_calibration_offset, buf, byte, 1024, idx);
+                } while (++idx & 0x7);
+              fprintf(fp, " -");
+              do
+                {
+                  sram_dump_byte(fp, expected, loc, end_calibration_offset, buf, byte, 1024, idx);
+                } while (++idx & 0x7);
+
+
+              fputs("\n", fp);
+              byte += 16;
+              loc += 16;
+            }
+        }
+      fprintf(fp, "
"); + fclose(fp); + } +} +#endif static int rts8801_doscan (unsigned width, @@ -2610,13 +2755,13 @@ rts8801_doscan (unsigned width, int oddfirst, unsigned char const *calib_info, int merged_channels, - detailed_calibration_data const *detailed_calib_data) + double *postprocess_offsets, + double *postprocess_gains) { unsigned rowbytes = 0; unsigned output_rowbytes = 0; unsigned channels = 0; unsigned total_rows = 0; - unsigned bytesperchannel; unsigned char *row_buffer; unsigned char *output_buffer; unsigned buffered_rows; @@ -2638,7 +2783,7 @@ rts8801_doscan (unsigned width, channels = 3; rowbytes = width * 3; - bytesperchannel = width; + switch (colour) { case HP3500_GRAY_SCAN: @@ -2710,32 +2855,27 @@ rts8801_doscan (unsigned width, if (!rows_to_begin || !--rows_to_begin) { unsigned char *outnow = output_buffer; + unsigned x; - for (i = 0; - i < (merged_channels ? rowbytes : width); - i += merged_channels ? channels : 1) + for (i = x = 0; + x < width; + ++x, i += merged_channels ? channels : 1) { for (j = 0; j < channels; ++j) { unsigned pix = (unsigned char) channel_data[j][i & 1][i]; - if (detailed_calib_data) - { - unsigned char const *calib_start = - detailed_calib_data->channeldata[j] + - 2 * - detailed_calib_data-> - resolution_divisor * i / - (merged_channels ? channels : 1); - pix = - constrain ((int) pix - - (int) calib_start[0], 0, - 255); - pix = - constrain (pix * calib_start[1] / - 0x40, 0, 255); - } + if (postprocess_gains && postprocess_offsets) + { + int ppidx = j * width + x; + + pix = constrain ( pix + * postprocess_gains[ppidx] + - postprocess_offsets[ppidx], + 0, + 255); + } *outnow++ = pix; } } @@ -2818,6 +2958,9 @@ static unsigned local_sram_size; static unsigned char r93setting; #define RTS8801_F_SUPPRESS_MOVEMENT 1 +#define RTS8801_F_LAMP_OFF 2 +#define RTS8801_F_NO_DISPLACEMENTS 4 +#define RTS8801_F_ODDX 8 static int find_resolution_index (unsigned resolution) @@ -2848,7 +2991,8 @@ rts8801_fullscan (unsigned x, int green_calib_offset, int blue_calib_offset, int end_calib_offset, - detailed_calibration_data const *detailed_calib_data) + double *postprocess_offsets, + double *postprocess_gains) { int ires, jres; int tg_setting; @@ -2856,6 +3000,10 @@ rts8801_fullscan (unsigned x, unsigned char offdutytime; int result; int scan_frequency; + unsigned intra_channel_offset; + unsigned red_green_offset; + unsigned green_blue_offset; + unsigned total_offsets; ires = find_resolution_index (xresolution); jres = find_resolution_index (yresolution); @@ -2889,47 +3037,32 @@ rts8801_fullscan (unsigned x, rt_set_movement_pattern (regs, 0x800000); - - tg_setting = resparms[jres].tg; - rt_set_ccd_shift_clock_multiplier (regs, tg_info[tg_setting].tg_cph0p); - rt_set_ccd_clock_reset_interval (regs, tg_info[tg_setting].tg_crsp); - rt_set_ccd_clamp_clock_multiplier (regs, tg_info[tg_setting].tg_cclpp); - - - rt_set_one_register (0xc6, 0); - rt_set_one_register (0xc6, 0); - - rt_set_step_size (regs, resparms[jres].step_size); - rt_set_direction_forwards (regs); - rt_set_stop_when_rewound (regs, 0); - rt_set_data_feed_on (regs); - rt_set_calibration_addresses (regs, 0, 0, 0, 0); + rt_set_calibration_addresses (regs, 0, 0, 0, 0, 0); rt_set_basic_calibration (regs, calib_info[0], calib_info[1], calib_info[2], calib_info[3], calib_info[4], calib_info[5], calib_info[6], calib_info[7], calib_info[8]); regs[0x0b] = 0x70; /* If set to 0x71, the alternative, all values are low */ + regs[0x40] &= 0xc0; if (red_calib_offset >= 0 && green_calib_offset >= 0 - && blue_calib_offset >= 0 && - yresolution < 400) + && blue_calib_offset >= 0) { rt_set_calibration_addresses (regs, red_calib_offset, green_calib_offset, blue_calib_offset, - end_calib_offset); + end_calib_offset, + w); regs[0x40] |= 0x2f; - detailed_calib_data = 0; } else if (end_calib_offset >= 0) { rt_set_calibration_addresses (regs, 0x600, 0x600, 0x600, - end_calib_offset); - regs[0x40] &= 0xc0; + end_calib_offset, w); } rt_set_channel (regs, RT_CHANNEL_ALL); @@ -2937,23 +3070,9 @@ rts8801_fullscan (unsigned x, rt_set_merge_channels (regs, 1); rt_set_colour_mode (regs, 1); - rt_set_motor_movement_clock_multiplier (regs, - resparms[jres]. - motor_movement_clock_multiplier); - - rt_set_cdss (regs, tg_info[tg_setting].tg_cdss1, - tg_info[tg_setting].tg_cdss2); - rt_set_cdsc (regs, tg_info[tg_setting].tg_cdsc1, - tg_info[tg_setting].tg_cdsc2); - rt_update_after_setting_cdss2 (regs); - rt_set_last_sram_page (regs, (local_sram_size - 1) >> 5); - regs[0x39] = resparms[jres].reg_39_value; - regs[0xc3] = (regs[0xc3] & 0xf8) | resparms[jres].reg_c3_value; - regs[0xc6] = (regs[0xc6] & 0xf8) | resparms[jres].reg_c6_value; scan_frequency = resparms[jres].scan_frequency; - rt_set_scan_frequency (regs, scan_frequency); rt_set_cph0s (regs, resparms[ires].cph0s); if (resparms[ires].d3_bit_3_value) regs[0xd3] |= 0x08; @@ -2962,15 +3081,10 @@ rts8801_fullscan (unsigned x, if (flags & RTS8801_F_SUPPRESS_MOVEMENT) regs[0xc3] &= 0x7f; - rt_set_horizontal_resolution (regs, xresolution); - rt_set_noscan_distance (regs, y * scan_frequency - 1); - rt_set_total_distance (regs, scan_frequency * - (y + - h + - resparms[jres].red_green_offset + - resparms[jres].green_blue_offset + - resparms[jres].intra_channel_offset) - 1); + regs[0xb2] &= 0xf7; + + rt_set_horizontal_resolution (regs, xresolution); rt_set_scanline_start (regs, x * (1200 / xresolution) / @@ -2982,6 +3096,118 @@ rts8801_fullscan (unsigned x, (resparms[ires].cph0s ? 1 : 2) / (resparms[ires].d3_bit_3_value ? 1 : 2)); + if (flags & RTS8801_F_NO_DISPLACEMENTS) + { + red_green_offset = green_blue_offset = intra_channel_offset = 0; + } + else + { + red_green_offset = resparms[jres].red_green_offset; + green_blue_offset = resparms[jres].green_blue_offset; + intra_channel_offset = resparms[jres].intra_channel_offset; + } + total_offsets = red_green_offset + green_blue_offset + intra_channel_offset; + if (y > total_offsets + 2) + y -= total_offsets; + h += total_offsets; + + if (yresolution > 75 && !(flags & RTS8801_F_SUPPRESS_MOVEMENT)) + { + int rmres = find_resolution_index (50); + + if (rmres >= 0) + { + int factor = yresolution / 50; + int fastres = y / factor; + int remainder = y % factor; + + while (remainder < 2) + { + --fastres; + remainder += factor; + } + + if (fastres >= 3) + { + y = remainder; + + rt_set_noscan_distance(regs, fastres * resparms[rmres].scan_frequency - 2); + rt_set_total_distance(regs, fastres * resparms[rmres].scan_frequency - 1); + + rt_set_scan_frequency(regs, 1); + + tg_setting = resparms[rmres].tg; + rt_set_ccd_shift_clock_multiplier (regs, tg_info[tg_setting].tg_cph0p); + rt_set_ccd_clock_reset_interval (regs, tg_info[tg_setting].tg_crsp); + rt_set_ccd_clamp_clock_multiplier (regs, tg_info[tg_setting].tg_cclpp); + + rt_set_one_register (0xc6, 0); + rt_set_one_register (0xc6, 0); + + rt_set_step_size (regs, resparms[rmres].step_size); + + rt_set_motor_movement_clock_multiplier (regs, + resparms[rmres]. + motor_movement_clock_multiplier); + + rt_set_cdss (regs, tg_info[tg_setting].tg_cdss1, + tg_info[tg_setting].tg_cdss2); + rt_set_cdsc (regs, tg_info[tg_setting].tg_cdsc1, + tg_info[tg_setting].tg_cdsc2); + rt_update_after_setting_cdss2 (regs); + + regs[0x39] = resparms[rmres].reg_39_value; + regs[0xc3] = (regs[0xc3] & 0xf8) | resparms[rmres].reg_c3_value; + regs[0xc6] = (regs[0xc6] & 0xf8) | resparms[rmres].reg_c6_value; + + rt_set_data_feed_off (regs); + + rt_set_all_registers (regs); + + rt_set_one_register (0x2c, regs[0x2c]); + + if (DBG_LEVEL >= 5) + dump_registers (regs); + + rt_start_moving (); + while (rt_is_moving ()); + } + } + } + + + rt_set_noscan_distance (regs, y * scan_frequency - 1); + rt_set_total_distance (regs, scan_frequency * (y + h) - 1); + + rt_set_scan_frequency (regs, scan_frequency); + + tg_setting = resparms[jres].tg; + + rt_set_ccd_shift_clock_multiplier (regs, tg_info[tg_setting].tg_cph0p); + rt_set_ccd_clock_reset_interval (regs, tg_info[tg_setting].tg_crsp); + rt_set_ccd_clamp_clock_multiplier (regs, tg_info[tg_setting].tg_cclpp); + + rt_set_one_register (0xc6, 0); + rt_set_one_register (0xc6, 0); + + rt_set_step_size (regs, resparms[jres].step_size); + + rt_set_motor_movement_clock_multiplier (regs, + resparms[jres]. + motor_movement_clock_multiplier); + + rt_set_cdss (regs, tg_info[tg_setting].tg_cdss1, + tg_info[tg_setting].tg_cdss2); + rt_set_cdsc (regs, tg_info[tg_setting].tg_cdsc1, + tg_info[tg_setting].tg_cdsc2); + rt_update_after_setting_cdss2 (regs); + + regs[0x39] = resparms[jres].reg_39_value; + regs[0xc3] = (regs[0xc3] & 0xf8) | resparms[jres].reg_c3_value; + regs[0xc6] = (regs[0xc6] & 0xf8) | resparms[jres].reg_c6_value; + + rt_set_data_feed_on (regs); + rt_set_all_registers (regs); rt_set_one_register (0x2c, regs[0x2c]); @@ -2992,12 +3218,13 @@ rts8801_fullscan (unsigned x, result = rts8801_doscan (w, h, colour, - resparms[jres].red_green_offset, - resparms[jres].green_blue_offset, - resparms[jres].intra_channel_offset, + red_green_offset, + green_blue_offset, + intra_channel_offset, cbfunc, param, (x & 1), calib_info, - (regs[0x2f] & 0x04) != 0, detailed_calib_data); - + (regs[0x2f] & 0x04) != 0, + postprocess_offsets, + postprocess_gains); return result; } @@ -3080,6 +3307,11 @@ sum_channel (unsigned char *p, int n, int bytwo) static int do_warmup = 1; +#define DETAILED_PASS_COUNT 3 +#define DETAILED_PASS_OFFSETS 0 +#define DETAILED_PASS_GAINS_FIRSTPASS 1 +#define DETAILED_PASS_GAINS_SECONDPASS 2 + static int rts8801_scan (unsigned x, unsigned y, @@ -3090,26 +3322,22 @@ rts8801_scan (unsigned x, unsigned brightness, unsigned contrast, rts8801_callback cbfunc, - void *param) + void *param, + double gamma) { unsigned char calib_info[9]; unsigned char calibbuf[2400]; struct dcalibdata dcd; struct calibdata cd; unsigned char *detail_buffer = 0; - int iCalibOffset; - int iCalibX; int iCalibY; - int iCalibWidth; int iCalibTarget; - int iCalibPixels; int iMoveFlags = 0; - unsigned int aiLow[3] = { 0, 0, 0 }; - unsigned int aiHigh[3] = { 256, 256, 256 }; - unsigned aiBestOffset[3]; + unsigned aiBestOffset[6]; + int aiPassed[6]; int i; unsigned j; - int anychanged; + int k; int calibration_size; unsigned char *pDetailedCalib; int red_calibration_offset; @@ -3121,7 +3349,13 @@ rts8801_scan (unsigned x, int resolution_index; int detailed_calibration_rows = 50; unsigned char *tdetail_buffer; - detailed_calibration_data detailed_calib_data; + int pass; + int onechanged; + double *postprocess_gains; + double *postprocess_offsets; + int needs_postprocessed_calibration = 0; + double contrast_adjust = (double) contrast / 64; + int brightness_adjust = brightness - 0x80; /* Initialise and power up */ @@ -3150,99 +3384,101 @@ rts8801_scan (unsigned x, calib_info[2] = calib_info[5] = calib_info[8] = 1; - calib_info[0] = calib_info[1] = calib_info[3] = calib_info[4] = - calib_info[6] = calib_info[7] = 0xb4; - - iCalibOffset = 0; /* Note that horizontal resolution is always 600dpi for calibration. 330 is 110 dots in (for R,G,B channels) */ - iCalibX = 1; - iCalibPixels = 50; - iCalibY = (resolution == 25) ? 1 : 2; /* Was 1200 / resolution, which would take us past the calibration area for 50dpi */ - iCalibWidth = 100; + iCalibY = (resolution == 25) ? 1 : 2; iCalibTarget = 550; + + rt_turn_off_lamp(); - for (i = 0; i < 3; ++i) - aiBestOffset[i] = 0xb4; - + for (i = 0; i < 6; ++i) + { + aiBestOffset[i] = 0xbf; + aiPassed[i] = 0; + } + do { DBG (30, "Initial calibration pass commences\n"); - anychanged = 0; - - for (i = 0; i < 3; ++i) - { - aiBestOffset[i] = (aiHigh[i] + aiLow[i] + 1) / 2; - } + onechanged = 0; for (i = 0; i < 3; ++i) - calib_info[i * 3] = calib_info[i * 3 + 1] = aiBestOffset[i]; - + { + calib_info[i * 3] = aiBestOffset[i]; + calib_info[i * 3 + 1] = aiBestOffset[i + 3]; + } + cd.buffer = calibbuf; cd.space = sizeof (calibbuf); DBG (30, "Commencing scan for initial calibration pass\n"); - rts8801_fullscan (iCalibX, iCalibY, iCalibWidth, 2, 600, resolution, + rts8801_fullscan (1401, iCalibY, 100, 2, 400, resolution, HP3500_COLOR_SCAN, (rts8801_callback) storefunc, &cd, - calib_info, iMoveFlags, -1, -1, -1, -1, 0); + calib_info, iMoveFlags, -1, -1, -1, -1, 0, 0); DBG (30, "Completed scan for initial calibration pass\n"); - iMoveFlags = RTS8801_F_SUPPRESS_MOVEMENT; + iMoveFlags = RTS8801_F_SUPPRESS_MOVEMENT | RTS8801_F_NO_DISPLACEMENTS; + iCalibY = 2; - for (i = 0; i < 3; ++i) + for (i = 0; i < 6; ++i) { int sum; - if (aiBestOffset[i] >= 255) + if (aiBestOffset[i] >= 255 || aiPassed[i] > 2) continue; - sum = sum_channel (calibbuf + iCalibOffset + i, iCalibPixels, 0); + sum = sum_channel (calibbuf + i, 50, 1); DBG (20, "channel[%d] sum = %d (target %d)\n", i, sum, iCalibTarget); - if (sum >= iCalibTarget) - aiHigh[i] = aiBestOffset[i]; - else - aiLow[i] = aiBestOffset[i]; + if (sum < iCalibTarget) + { + onechanged = 1; + ++aiBestOffset[i]; + } + else + { + ++aiPassed[i]; + } } DBG (30, "Initial calibration pass completed\n"); } - while (aiLow[0] < aiHigh[0] - 1 && aiLow[1] < aiHigh[1] - 1 - && aiLow[1] < aiHigh[1] + 1); + while (onechanged); DBG (20, "Offsets calculated\n"); - cd.buffer = calibbuf; - cd.space = sizeof (calibbuf); - DBG (20, "Scanning for part 2 of initial calibration\n"); - rts8801_fullscan (iCalibX + 2100, iCalibY, iCalibWidth, 2, 600, resolution, - HP3500_COLOR_SCAN, (rts8801_callback) storefunc, &cd, - calib_info, RTS8801_F_SUPPRESS_MOVEMENT, -1, -1, -1, -1, - 0); - DBG (20, "Scan for part 2 of initial calibration completed\n"); - DBG (20, "Initial calibration completed\n"); + rt_turn_on_lamp(); + usleep(500000); tdetail_buffer = (unsigned char *) malloc (w * 3 * detailed_calibration_rows); - aiLow[0] = aiLow[1] = aiLow[2] = 1; - aiHigh[0] = aiHigh[1] = aiHigh[2] = 64; + for (i = 0; i < 3; ++i) + { + calib_info[i * 3 + 2] = 1; + aiPassed[i] = 0; + } + do { struct dcalibdata dcdt; - for (i = 0; i < 3; ++i) - calib_info[i * 3 + 2] = (aiLow[i] + aiHigh[i]) / 2; - dcdt.buffers[0] = tdetail_buffer; dcdt.buffers[1] = (tdetail_buffer + w * detailed_calibration_rows); dcdt.buffers[2] = (dcdt.buffers[1] + w * detailed_calibration_rows); dcdt.pixelsperrow = w; dcdt.pixelnow = dcdt.channelnow = dcdt.firstrowdone = 0; + DBG (20, "Scanning for part 2 of initial calibration\n"); rts8801_fullscan (x, 4, w, detailed_calibration_rows + 1, resolution, resolution, HP3500_COLOR_SCAN, (rts8801_callback) accumfunc, &dcdt, calib_info, - RTS8801_F_SUPPRESS_MOVEMENT, -1, -1, -1, -1, 0); + RTS8801_F_SUPPRESS_MOVEMENT | RTS8801_F_NO_DISPLACEMENTS, -1, -1, -1, -1, 0, 0); + DBG (20, "Scan for part 2 of initial calibration completed\n"); + + onechanged = 0; for (i = 0; i < 3; ++i) { int largest = 1; - for (j = 0; j < w; ++j) + if (aiPassed[i] > 2 || calib_info[i * 3 + 2] >= 63) + continue; + + for (j = 0; j < w; ++j) { int val = calcmedian (dcdt.buffers[i], j, w, detailed_calibration_rows); @@ -3252,16 +3488,17 @@ rts8801_scan (unsigned x, } if (largest < 0xe0) - aiLow[i] = calib_info[i * 3 + 2]; - else - aiHigh[i] = calib_info[i * 3 + 2]; + { + ++calib_info[i * 3 + 2]; + onechanged = 1; + } + else + { + ++aiPassed[i]; + } } } - while (aiLow[0] < aiHigh[0] - 1 && aiLow[1] < aiHigh[1] - 1 - && aiLow[1] < aiHigh[1] + 1); - - for (i = 0; i < 3; ++i) - calib_info[i * 3 + 2] = aiLow[i]; + while (onechanged); for (i = 0; i < 3; ++i) { @@ -3282,15 +3519,7 @@ rts8801_scan (unsigned x, dcd.buffers[1] = (detail_buffer + w * detailed_calibration_rows); dcd.buffers[2] = (dcd.buffers[1] + w * detailed_calibration_rows); dcd.pixelsperrow = w; - dcd.pixelnow = dcd.channelnow = dcd.firstrowdone = 0; - - DBG (10, "Performing detailed calibration scan\n"); - rts8801_fullscan (x, iCalibY, w, detailed_calibration_rows + 1, - resolution, resolution, HP3500_COLOR_SCAN, - (rts8801_callback) accumfunc, &dcd, calib_info, - RTS8801_F_SUPPRESS_MOVEMENT, -1, -1, -1, -1, 0); - DBG (10, "Detailed calibration scan completed\n"); /* And now for the detailed calibration */ resolution_index = find_resolution_index (resolution); @@ -3301,101 +3530,221 @@ rts8801_scan (unsigned x, base_resolution *= 2; resolution_divisor = base_resolution / resolution; - calibration_size = w * resolution_divisor * 6 + 1536; - red_calibration_offset = 1536; - blue_calibration_offset = - red_calibration_offset + w * resolution_divisor * 2; + calibration_size = w * resolution_divisor * 6 + 1568 + 96; + red_calibration_offset = 0x600; green_calibration_offset = - blue_calibration_offset + w * resolution_divisor * 2; - end_calibration_offset = + red_calibration_offset + w * resolution_divisor * 2; + blue_calibration_offset = green_calibration_offset + w * resolution_divisor * 2; + end_calibration_offset = + blue_calibration_offset + w * resolution_divisor * 2; pDetailedCalib = (unsigned char *) malloc (calibration_size); memset (pDetailedCalib, 0, calibration_size); + for (i = 0; i < 3; ++i) { int idx = - (i == 0) ? red_calibration_offset : (i == - 1) ? green_calibration_offset : - blue_calibration_offset; - double g = calib_info[i * 3 + 2]; + (i == 0) ? red_calibration_offset : + (i == 1) ? green_calibration_offset : + blue_calibration_offset; for (j = 0; j < 256; j++) - { - int val = j; - - if (val < 0) - val = 0; - if (val > 255) - val = 255; - pDetailedCalib[i * 512 + j * 2] = val; - pDetailedCalib[i * 512 + j * 2 + 1] = val; - } + { + /* Gamma table - appears to be 256 byte pairs for each input + * range (so the first entry cover inputs in the range 0 to 1, + * the second 1 to 2, and so on), mapping that input range + * (including the fractional parts within it) to an output + * range. + */ + pDetailedCalib[i * 512 + j * 2] = j; + pDetailedCalib[i * 512 + j * 2 + 1] = j; + } for (j = 0; j < w; ++j) - { - int multnow; - int offnow; - - /* This seems to be the approach for reg 0x40 & 0x3f == 0x27, which allows detailed - * calibration to return either higher or lower values. - */ - int k; - - { - double denom1 = - calcmedian (dcd.buffers[i], j, w, detailed_calibration_rows); - double f = 0xff / (denom1 - 2 * g); - double contrast_adjust = (double) (contrast + 1) / 64; - - multnow = f * 64 * contrast_adjust; - offnow = 4 * g + 128 - brightness; - } - if (multnow < 0) - multnow = 0; - if (multnow > 255) - multnow = 255; - if (offnow < 0) - offnow = 0; - if (offnow > 255) - offnow = 255; - - for (k = 0; k < resolution_divisor; ++k) - { - /*multnow = j * resolution_divisor + k; */ - pDetailedCalib[idx++] = offnow; /* Subtract this value from the result */ - pDetailedCalib[idx++] = multnow; /* Then multiply by this value divided by 0x40 */ - } - } + { + for (k = 0; k < resolution_divisor; ++k) + { + pDetailedCalib[idx++] = 0; + pDetailedCalib[idx++] = 0x80; + } + } } - DBG (10, "\n"); - rt_set_sram_page (0); rt_set_one_register (0x93, r93setting); rt_write_sram (calibration_size, pDetailedCalib); - /* And finally, perform the scan */ + postprocess_gains = (double *) malloc(sizeof(double) * 3 * w); + postprocess_offsets = (double *) malloc(sizeof(double) * 3 * w); + + for (pass = 0; pass < DETAILED_PASS_COUNT; ++pass) + { + int ppidx = 0; + + DBG (10, "Performing detailed calibration scan %d\n", pass); + + switch (pass) + { + case DETAILED_PASS_OFFSETS: + rt_turn_off_lamp(); + usleep(500000); /* To be sure it has gone off */ + break; + + case DETAILED_PASS_GAINS_FIRSTPASS: + rt_turn_on_lamp(); + usleep(500000); /* Give the lamp time to settle */ + break; + } + + dcd.pixelnow = dcd.channelnow = dcd.firstrowdone = 0; + rts8801_fullscan (x, iCalibY, w, detailed_calibration_rows + 1, + resolution, resolution, HP3500_COLOR_SCAN, + (rts8801_callback) accumfunc, &dcd, + calib_info, + RTS8801_F_SUPPRESS_MOVEMENT | RTS8801_F_NO_DISPLACEMENTS, + red_calibration_offset, + green_calibration_offset, + blue_calibration_offset, + end_calibration_offset, + 0, 0); + + DBG (10, " Detailed calibration scan %d completed\n", pass); + + for (i = 0; i < 3; ++i) + { + int idx = + (i == 0) ? red_calibration_offset : + (i == 1) ? green_calibration_offset : + blue_calibration_offset; + + for (j = 0; j < w; ++j) + { + double multnow = 0x80; + int offnow = 0; + + /* This seems to be the approach for reg 0x40 & 0x3f == 0x27, which allows detailed + * calibration to return either higher or lower values. + */ + + { + double denom1 = + calcmedian (dcd.buffers[i], j, w, detailed_calibration_rows); + + switch (pass) + { + case DETAILED_PASS_OFFSETS: + /* The offset is the number needed to be subtracted from "black" at detailed gain = 0x80, + * which is the value we started with. For the next round, pull the gain down to 0x20. Our + * next scan is a test scan to confirm the offset works. + */ + multnow = 0x20; + offnow = denom1; + break; + + case DETAILED_PASS_GAINS_FIRSTPASS: + multnow = 128.0 / denom1 * 0x20; /* Then bring it up to whatever we need to hit 192 */ + if (multnow > 255) + multnow = 255; + offnow = pDetailedCalib[idx]; + break; + + case DETAILED_PASS_GAINS_SECONDPASS: + multnow = 255.0 / denom1 * contrast_adjust * pDetailedCalib[idx+1]; /* And finally to 255 */ + offnow = pDetailedCalib[idx] - brightness_adjust * 0x80 / multnow; + + if (offnow < 0) + { + postprocess_offsets[ppidx] = multnow * offnow / 0x80; + offnow = 0; + needs_postprocessed_calibration = 1; + } + else if (offnow > 255) + { + postprocess_offsets[ppidx] = multnow * (offnow - 255) / 0x80; + offnow = 255; + needs_postprocessed_calibration = 1; + } + else + { + postprocess_offsets[ppidx] = 0; + } + if (multnow > 255) + { + postprocess_gains[ppidx] = multnow / 255; + multnow = 255; + needs_postprocessed_calibration = 1; + } + else + { + postprocess_gains[ppidx] = 1.0; + } + break; + } + } + if (offnow > 255) + offnow = 255; + + for (k = 0; k < resolution_divisor; ++k) + { + pDetailedCalib[idx++] = offnow; /* Subtract this value from the result at gains = 0x80*/ + pDetailedCalib[idx++] = multnow; /* Then multiply by this value divided by 0x80 */ + } + ++ppidx; + } + } + + if (pass == DETAILED_PASS_GAINS_SECONDPASS) + { + /* Build gamma table */ + unsigned char *redgamma = pDetailedCalib; + unsigned char *greengamma = redgamma + 512; + unsigned char *bluegamma = greengamma + 512; + double val; + double invgamma = 1.0l / gamma; + + *redgamma++ = *bluegamma++ = *greengamma++ = 0; + + /* The windows driver does a linear interpolation for the next 19 boundaries */ + val = pow (20.0l / 255, invgamma) * 255; + + for (j = 1; j <= 20; ++j) + { + *redgamma++ = *bluegamma++ = *greengamma++ = val * j / 20 + 0.5; + *redgamma++ = *bluegamma++ = *greengamma++ = val * j / 20 + 0.5; + } + + for (; j <= 255; ++j) + { + val = pow((double) j / 255, invgamma) * 255; + + *redgamma++ = *bluegamma++ = *greengamma++ = val + 0.5; + *redgamma++ = *bluegamma++ = *greengamma++ = val + 0.5; + } + *redgamma++ = *bluegamma++ = *greengamma++ = 255; + } + + DBG (10, "\n"); + + rt_set_sram_page (0); + rt_set_one_register (0x93, r93setting); + rt_write_sram (calibration_size, pDetailedCalib); + } + /* And finally, perform the scan */ DBG (10, "Scanning\n"); rts8801_rewind (); - detailed_calib_data.channeldata[0] = - pDetailedCalib + red_calibration_offset; - detailed_calib_data.channeldata[1] = - pDetailedCalib + green_calibration_offset; - detailed_calib_data.channeldata[2] = - pDetailedCalib + blue_calibration_offset; - detailed_calib_data.resolution_divisor = resolution_divisor; - rts8801_fullscan (x, y, w, h, resolution, resolution, colour, cbfunc, param, calib_info, 0, red_calibration_offset, green_calibration_offset, blue_calibration_offset, end_calibration_offset, - &detailed_calib_data); + needs_postprocessed_calibration ? postprocess_offsets : 0, + needs_postprocessed_calibration ? postprocess_gains : 0); rt_turn_off_lamp (); + rts8801_rewind (); rt_set_powersave_mode (1); @@ -3403,6 +3752,12 @@ rts8801_scan (unsigned x, free (pDetailedCalib); if (detail_buffer) free (detail_buffer); + if (tdetail_buffer) + free(tdetail_buffer); + if (postprocess_gains) + free(postprocess_gains); + if (postprocess_offsets) + free(postprocess_offsets); return 0; } @@ -3466,7 +3821,6 @@ reader_process (void *pv) sigaction (SIGTERM, &act, 0); } - /* Warm up the lamp again if our last scan ended more than 5 minutes ago. */ time (&t); do_warmup = (t - scanner->last_scan) > 300; @@ -3498,9 +3852,25 @@ reader_process (void *pv) scanner->actres_pixels.right - scanner->actres_pixels.left, scanner->actres_pixels.bottom - scanner->actres_pixels.top, scanner->resolution, scanner->mode, scanner->brightness, - scanner->contrast, (rts8801_callback) writefunc, &winfo) >= 0) + scanner->contrast, (rts8801_callback) writefunc, &winfo, + scanner->gamma) >= 0) status = SANE_STATUS_GOOD; status = SANE_STATUS_IO_ERROR; close (scanner->pipe_w); return status; } + +static size_t +max_string_size (char const **strings) +{ + size_t size, max_size = 0; + SANE_Int i; + + for (i = 0; strings[i]; ++i) + { + size = strlen (strings[i]) + 1; + if (size > max_size) + max_size = size; + } + return max_size; +} diff --git a/backend/hp3900_sane.c b/backend/hp3900_sane.c index b815572..410e35e 100644 --- a/backend/hp3900_sane.c +++ b/backend/hp3900_sane.c @@ -1159,7 +1159,7 @@ options_init (TScanner * scanner) TOptionValue *pVal; /* set gamma */ - gamma_create (scanner, 2.2); + gamma_create (scanner, 1.0); /* color convertion */ scanner->cnv.colormode = -1; diff --git a/backend/hp4200.c b/backend/hp4200.c index a069be6..589157d 100644 --- a/backend/hp4200.c +++ b/backend/hp4200.c @@ -698,7 +698,6 @@ compute_first_gain_offset (int target, int max, int min, int *gain, static int write_gamma (HP4200_Scanner * s) { - SANE_Status status; int color; int i; unsigned char gamma[1024]; @@ -728,7 +727,7 @@ write_gamma (HP4200_Scanner * s) sanei_pv8630_write_byte (s->fd, PV8630_REPPADDRESS, 0x06); sanei_pv8630_prep_bulkread (s->fd, sizeof (read_gamma)); to_read = sizeof (read_gamma); - status = sanei_usb_read_bulk (s->fd, read_gamma, &to_read); + sanei_usb_read_bulk (s->fd, read_gamma, &to_read); retval = memcmp (read_gamma, gamma, sizeof (read_gamma)); if (retval != 0) { @@ -1047,7 +1046,6 @@ do_coarse_calibration (HP4200_Scanner * s, struct coarse_t *coarse) int step_size; int ff_step_size; char steps_to_reverse; - char hdpi_div; char line_rate_color; int vdpi; /* vertical dots per inch */ int hdpi_code; @@ -1085,7 +1083,6 @@ do_coarse_calibration (HP4200_Scanner * s, struct coarse_t *coarse) vdpi = 150; hdpi_code = 0; - hdpi_div = hdpi_mapping[hdpi_code]; active_pixels_start = 0x40; line_end = 0x2ee0; s->mclk_div = 2; @@ -1395,7 +1392,6 @@ do_fine_calibration (HP4200_Scanner * s, struct coarse_t *coarse) int vdpi; /* vertical dots per inch */ int hdpi_code; int calibrated; - int first_time; int lines_to_process; static char me[] = "do_fine_calibration"; @@ -1495,7 +1491,6 @@ do_fine_calibration (HP4200_Scanner * s, struct coarse_t *coarse) cache_write (s); calibrated = 0; - first_time = 1; cal_line = malloc (cal_line_size + 1024); average = malloc (sizeof (int) * line_length * 3); memset (average, 0, sizeof (int) * line_length * 3); @@ -2437,7 +2432,7 @@ sane_exit (void) } if (device->dev.name) { - free (device->dev.name); + free ((void *) device->dev.name); } free (device); } diff --git a/backend/hp5400.c b/backend/hp5400.c index 61de3db..cfa2dc9 100644 --- a/backend/hp5400.c +++ b/backend/hp5400.c @@ -67,6 +67,9 @@ #include /* malloc, free */ #include /* memcpy */ #include +#ifdef HAVE_SYS_TYPES_H +#include +#endif #define HP5400_CONFIG_FILE "hp5400.conf" diff --git a/backend/hp5400_internal.c b/backend/hp5400_internal.c index d7e2325..65a434f 100644 --- a/backend/hp5400_internal.c +++ b/backend/hp5400_internal.c @@ -282,7 +282,9 @@ SetCalibration (int iHandle, int numPixels, unsigned int *low_vals[3], cmd[3] = 0x00; cmd[4] = 0x54; cmd[5] = 0x02; - cmd[6] = 0x80; + cmd[6] = -128; // 0x80; fixes compiler warning (for + // signed char implementations), see + // also comment above cmd[7] = 0x00; hp5400_bulk_command_write (iHandle, 0xE603, cmd, 8, calSize, calSize, diff --git a/backend/hp5590.c b/backend/hp5590.c index 7b1cd60..fabf40a 100644 --- a/backend/hp5590.c +++ b/backend/hp5590.c @@ -48,6 +48,9 @@ #include #include #include +#ifdef HAVE_SYS_TYPES_H +#include +#endif #include "../include/sane/sane.h" #define BACKEND_NAME hp5590 @@ -168,7 +171,7 @@ calc_image_params (struct hp5590_scanner *scanner, unsigned int _image_size; float var; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); if (!scanner) return SANE_STATUS_INVAL; @@ -196,7 +199,7 @@ calc_image_params (struct hp5590_scanner *scanner, DBG (DBG_verbose, "%s: pixel_bits: %u, pixels_per_line: %u, " "bytes_per_line: %u, lines: %u, image_size: %u\n", - __FUNCTION__, + __func__, _pixel_bits, _pixels_per_line, _bytes_per_line, _lines, _image_size); if (pixel_bits) @@ -229,10 +232,10 @@ attach_usb_device (SANE_String_Const devname, SANE_Status ret; const struct hp5590_model *hp5590_model; - DBG (DBG_proc, "%s: Opening USB device\n", __FUNCTION__); + DBG (DBG_proc, "%s: Opening USB device\n", __func__); if (sanei_usb_open (devname, &dn) != SANE_STATUS_GOOD) return SANE_STATUS_IO_ERROR; - DBG (DBG_proc, "%s: USB device opened\n", __FUNCTION__); + DBG (DBG_proc, "%s: USB device opened\n", __func__); ret = hp5590_model_def (hp_scanner_type, &hp5590_model); if (ret != SANE_STATUS_GOOD) @@ -243,19 +246,19 @@ attach_usb_device (SANE_String_Const devname, return SANE_STATUS_IO_ERROR; DBG (1, "%s: found HP%s scanner at '%s'\n", - __FUNCTION__, info->model, devname); + __func__, info->model, devname); - DBG (DBG_verbose, "%s: Reading max scan count\n", __FUNCTION__); + DBG (DBG_verbose, "%s: Reading max scan count\n", __func__); if (hp5590_read_max_scan_count (dn, hp5590_model->proto_flags, &max_count) != 0) return SANE_STATUS_IO_ERROR; - DBG (DBG_verbose, "%s: Max Scanning count %u\n", __FUNCTION__, max_count); + DBG (DBG_verbose, "%s: Max Scanning count %u\n", __func__, max_count); - DBG (DBG_verbose, "%s: Reading scan count\n", __FUNCTION__); + DBG (DBG_verbose, "%s: Reading scan count\n", __func__); if (hp5590_read_scan_count (dn, hp5590_model->proto_flags, &count) != 0) return SANE_STATUS_IO_ERROR; - DBG (DBG_verbose, "%s: Scanning count %u\n", __FUNCTION__, count); + DBG (DBG_verbose, "%s: Scanning count %u\n", __func__, count); ret = hp5590_read_part_number (dn, hp5590_model->proto_flags); if (ret != SANE_STATUS_GOOD) @@ -381,7 +384,7 @@ void sane_exit (void) { struct hp5590_scanner *ptr, *pnext; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); for (ptr = scanners_list; ptr; ptr = pnext) { @@ -399,7 +402,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) struct hp5590_scanner *ptr; unsigned int found, i; - DBG (DBG_proc, "%s, local only: %u\n", __FUNCTION__, local_only); + DBG (DBG_proc, "%s, local only: %u\n", __func__, local_only); if (!device_list) return SANE_STATUS_INVAL; @@ -431,7 +434,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) SANE_String_Const *sources_list; unsigned int source_idx; - DBG (DBG_proc, "%s: device name: %s\n", __FUNCTION__, devicename); + DBG (DBG_proc, "%s: device name: %s\n", __func__, devicename); if (!handle) return SANE_STATUS_INVAL; @@ -623,7 +626,7 @@ sane_close (SANE_Handle handle) { struct hp5590_scanner *scanner = handle; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); sanei_usb_close (scanner->dn); scanner->dn = -1; @@ -635,7 +638,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct hp5590_scanner *scanner = handle; - DBG (DBG_proc, "%s, option: %u\n", __FUNCTION__, option); + DBG (DBG_proc, "%s, option: %u\n", __func__, option); if (option >= HP5590_OPT_LAST) return NULL; @@ -664,7 +667,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, { if (option == HP5590_OPT_NUM) { - DBG(3, "%s: get total number of options - %u\n", __FUNCTION__, HP5590_OPT_LAST); + DBG(3, "%s: get total number of options - %u\n", __func__, HP5590_OPT_LAST); *((SANE_Int *) value) = HP5590_OPT_LAST; return SANE_STATUS_GOOD; } @@ -672,7 +675,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (!scanner->opts) return SANE_STATUS_INVAL; - DBG (DBG_proc, "%s: get option '%s' value\n", __FUNCTION__, scanner->opts[option].name); + DBG (DBG_proc, "%s: get option '%s' value\n", __func__, scanner->opts[option].name); if (option == HP5590_OPT_BR_X) { @@ -923,7 +926,7 @@ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Status ret; unsigned int pixel_bits; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); if (!params) return SANE_STATUS_INVAL; @@ -961,7 +964,7 @@ SANE_Status sane_get_parameters (SANE_Handle handle, params->format = SANE_FRAME_RGB; break; default: - DBG(0, "%s: Unknown depth\n", __FUNCTION__); + DBG(0, "%s: Unknown depth\n", __func__); return SANE_STATUS_INVAL; } @@ -983,7 +986,7 @@ sane_start (SANE_Handle handle) SANE_Status ret; unsigned int bytes_per_line; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); if (!scanner) return SANE_STATUS_INVAL; @@ -993,11 +996,11 @@ sane_start (SANE_Handle handle) || scanner->source == SOURCE_ADF_DUPLEX)) { DBG (DBG_verbose, "%s: Scanner is scanning, check if more data is available\n", - __FUNCTION__); + __func__); ret = hp5590_is_data_available (scanner->dn, scanner->proto_flags); if (ret == SANE_STATUS_GOOD) { - DBG (DBG_verbose, "%s: More data is available\n", __FUNCTION__); + DBG (DBG_verbose, "%s: More data is available\n", __func__); scanner->transferred_image_size = scanner->image_size; return SANE_STATUS_GOOD; } @@ -1147,7 +1150,7 @@ convert_lineart (struct hp5590_scanner *scanner, SANE_Byte *data, SANE_Int size) { SANE_Int i; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_assert (scanner != NULL); hp5590_assert (data != NULL); @@ -1182,7 +1185,7 @@ convert_to_rgb (struct hp5590_scanner *scanner, SANE_Byte *data, SANE_Int size) || scanner->depth == DEPTH_GRAY) return SANE_STATUS_GOOD; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); #ifndef HAS_WORKING_COLOR_48 if (scanner->depth == DEPTH_COLOR_48) @@ -1263,7 +1266,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Status ret; DBG (DBG_proc, "%s, length %u, left %u\n", - __FUNCTION__, + __func__, max_length, scanner->transferred_image_size); @@ -1282,7 +1285,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data, if (ret != SANE_STATUS_GOOD) return ret; - /* Dont free bulk read state, some bytes could be left + /* Don't free bulk read state, some bytes could be left * for the next images from ADF */ return SANE_STATUS_EOF; @@ -1350,7 +1353,7 @@ sane_cancel (SANE_Handle handle) struct hp5590_scanner *scanner = handle; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); scanner->scanning = SANE_FALSE; @@ -1370,7 +1373,7 @@ SANE_Status sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); return SANE_STATUS_UNSUPPORTED; } @@ -1380,7 +1383,7 @@ SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); return SANE_STATUS_UNSUPPORTED; } diff --git a/backend/hp5590_cmds.c b/backend/hp5590_cmds.c index 894101b..06fd91a 100644 --- a/backend/hp5590_cmds.c +++ b/backend/hp5590_cmds.c @@ -483,7 +483,7 @@ hp5590_init_scanner (SANE_Int dn, * 09 60 4F B0 6D E0 00 00 00 00 00 00 00 00 00 64 ..O.m..........d * 03 E8 .. */ - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (init_resp) == 50); @@ -512,7 +512,7 @@ hp5590_init_scanner (SANE_Int dn, { DBG (DBG_err, "%s: Vendor id mismatch for scanner HP%s - " "required '%s', got '%s'\n", - __FUNCTION__, + __func__, hp5590_models[i].model, hp5590_models[i].vendor_id, id_buf); return SANE_STATUS_INVAL; @@ -593,10 +593,10 @@ hp5590_init_scanner (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: scanner reports non-zero status: %s\n", - __FUNCTION__, sane_strstatus (ret)); + __func__, sane_strstatus (ret)); return ret; } - DBG (DBG_cmds, "%s: scanner status OK\n", __FUNCTION__); + DBG (DBG_cmds, "%s: scanner status OK\n", __func__); return SANE_STATUS_GOOD; } @@ -614,7 +614,7 @@ hp5590_read_eeprom (SANE_Int dn, hp5590_cmds_assert (data != NULL); hp5590_cmds_assert (sizeof (eeprom_addr) == 1); - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); DBG (DBG_proc, "Reading EEPROM: addr %04x, size %u\n", addr, size); ret = hp5590_cmd (dn, @@ -649,7 +649,7 @@ hp5590_write_eeprom (SANE_Int dn, hp5590_cmds_assert (data != NULL); hp5590_cmds_assert (sizeof (eeprom_addr) == 1); - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); DBG (DBG_proc, "Writing EEPROM: addr %04x, size: %u\n", addr, size); ret = hp5590_cmd (dn, @@ -683,7 +683,7 @@ hp5590_read_scan_count (SANE_Int dn, hp5590_cmds_assert (count != NULL); hp5590_cmds_assert (sizeof (scan_count) == 4); - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); DBG (DBG_proc, "Reading scan count\n"); ret = hp5590_read_eeprom (dn, @@ -713,7 +713,7 @@ hp5590_inc_scan_count (SANE_Int dn, unsigned int new_count; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (scan_count) == 4); ret = hp5590_read_scan_count (dn, proto_flags, &count); @@ -756,7 +756,7 @@ hp5590_read_max_scan_count (SANE_Int dn, hp5590_cmds_assert (max_count != NULL); hp5590_cmds_assert (sizeof (max_scan_count) == 3); - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); DBG (DBG_proc, "Reading max scan count\n"); ret = hp5590_read_eeprom (dn, @@ -811,7 +811,7 @@ hp5590_read_eeprom_all_cmd (SANE_Int dn, uint8_t eeprom[255]; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); ret = hp5590_read_eeprom (dn, proto_flags, @@ -835,7 +835,7 @@ hp5590_read_part_number (SANE_Int dn, unsigned char part_number[PART_NUMBER_LEN + 1]; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); memset (part_number, 0, sizeof (part_number)); ret = hp5590_read_eeprom (dn, @@ -859,7 +859,7 @@ hp5590_is_data_available (SANE_Int dn, SANE_Status ret; SANE_Bool data_available; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (data_status) == 1); data_available = SANE_FALSE; @@ -873,13 +873,13 @@ hp5590_is_data_available (SANE_Int dn, if (ret != SANE_STATUS_GOOD) return ret; - DBG (DBG_cmds, "%s: Data status: %02x\n", __FUNCTION__, data_status); + DBG (DBG_cmds, "%s: Data status: %02x\n", __func__, data_status); if (data_status == 0x40) data_available = SANE_TRUE; DBG (DBG_cmds, "%s: Data is %s\n", - __FUNCTION__, + __func__, data_available == SANE_TRUE ? "available" : "not available"); return data_available == SANE_TRUE ? SANE_STATUS_GOOD : SANE_STATUS_NO_DOCS; @@ -893,7 +893,7 @@ hp5590_stop_scan (SANE_Int dn, uint8_t reg_011b = 0x40; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (reg_011b) == 1); @@ -920,7 +920,7 @@ hp5590_turnon_lamp (SANE_Int dn, struct lamp_state lamp_state; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (lamp_state) == 4); @@ -930,7 +930,7 @@ hp5590_turnon_lamp (SANE_Int dn, lamp_state.unk1 = 0x02; lamp_state.flag = 0x01; lamp_state.turnoff_time = htons (0x0a0a); - DBG (DBG_cmds, "%s: turning lamp on\n", __FUNCTION__); + DBG (DBG_cmds, "%s: turning lamp on\n", __func__); } if (state == LAMP_STATE_TURNOFF) @@ -939,7 +939,7 @@ hp5590_turnon_lamp (SANE_Int dn, lamp_state.unk1 = 0x02; lamp_state.flag = 0x02; lamp_state.turnoff_time = htons (0x0a0a); - DBG (DBG_cmds, "%s: turning lamp off\n", __FUNCTION__); + DBG (DBG_cmds, "%s: turning lamp off\n", __func__); } if (state == LAMP_STATE_SET_TURNOFF_TIME) @@ -948,7 +948,7 @@ hp5590_turnon_lamp (SANE_Int dn, lamp_state.unk1 = 0x02; lamp_state.flag = 0x03; lamp_state.turnoff_time = htons (0x0336); - DBG (DBG_cmds, "%s: setting turnoff time\n", __FUNCTION__); + DBG (DBG_cmds, "%s: setting turnoff time\n", __func__); } if (state == LAMP_STATE_SET_TURNOFF_TIME_LONG) @@ -957,7 +957,7 @@ hp5590_turnon_lamp (SANE_Int dn, lamp_state.unk1 = 0x02; lamp_state.flag = 0x03; lamp_state.turnoff_time = htons (0x0f36); - DBG (DBG_cmds, "%s: setting long turnoff time\n", __FUNCTION__); + DBG (DBG_cmds, "%s: setting long turnoff time\n", __func__); } ret = hp5590_cmd (dn, @@ -987,7 +987,7 @@ hp5590_power_status (SANE_Int dn, struct power_resp power_resp; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (power_resp) == 3); @@ -1023,7 +1023,7 @@ hp5590_read_error_code (SANE_Int dn, struct reg_03 reg_03; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (reg_03) == 3); hp5590_cmds_assert (adf_flags != NULL); @@ -1040,9 +1040,9 @@ hp5590_read_error_code (SANE_Int dn, if (ret != SANE_STATUS_GOOD) return ret; - DBG (DBG_cmds, "%s: adf_flags: %04x\n", __FUNCTION__, reg_03.adf_flags); - DBG (DBG_cmds, "%s: unk1 : %04x\n", __FUNCTION__, reg_03.unk1); - DBG (DBG_cmds, "%s: unk2 : %04x\n", __FUNCTION__, reg_03.unk2); + DBG (DBG_cmds, "%s: adf_flags: %04x\n", __func__, reg_03.adf_flags); + DBG (DBG_cmds, "%s: unk1 : %04x\n", __func__, reg_03.unk1); + DBG (DBG_cmds, "%s: unk2 : %04x\n", __func__, reg_03.unk2); *adf_flags = reg_03.adf_flags; @@ -1056,7 +1056,7 @@ hp5590_reset_scan_head (SANE_Int dn, { SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); ret = hp5590_turnon_lamp (dn, proto_flags, LAMP_STATE_TURNOFF); if (ret != SANE_STATUS_GOOD) @@ -1082,7 +1082,7 @@ hp5590_select_source_and_wakeup (SANE_Int dn, SANE_Status ret; unsigned int adf_flags; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (reg_d6) == 1); @@ -1161,7 +1161,7 @@ hp5590_lock_unlock_scanner (SANE_Int dn, unsigned int adf_flags; unsigned int waiting; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (reg_00) == 1); for (waiting = 0; waiting < WAKEUP_TIMEOUT; waiting++, sleep (1)) @@ -1206,7 +1206,7 @@ hp5590_set_base_dpi (SANE_Int dn, uint16_t _base_dpi; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (scanner_info != NULL); hp5590_cmds_assert (base_dpi != 0); @@ -1246,7 +1246,7 @@ hp5590_set_color_map (SANE_Int dn, struct color_map color_map; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (color_map) == 18); hp5590_cmds_assert (base_dpi != 0); @@ -1301,7 +1301,7 @@ static SANE_Status calc_base_dpi (unsigned int dpi, unsigned int *base_dpi) { - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (base_dpi != NULL); hp5590_cmds_assert (dpi != 0); @@ -1346,7 +1346,7 @@ calc_base_dpi (unsigned int dpi, unsigned int *base_dpi) static SANE_Status calc_scanner_dpi (unsigned int dpi, unsigned int *scanner_dpi) { - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (scanner_dpi != NULL); hp5590_cmds_assert (dpi != 0); @@ -1399,7 +1399,7 @@ hp5590_calc_pixel_bits (unsigned int dpi, enum color_depths color_depth, unsigned int scanner_dpi; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (pixel_bits != NULL); hp5590_cmds_assert (dpi != 0); @@ -1465,7 +1465,7 @@ hp5590_set_scan_area (SANE_Int dn, unsigned int pixels_y; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (scan_params) == 37); hp5590_cmds_assert (dpi != 0); @@ -1579,14 +1579,14 @@ hp5590_set_scan_area (SANE_Int dn, if (top_x + pixels_x > max_pixels_x_current_dpi) { - DBG (DBG_err, "Top X (%u) + pixels X (%u) exceedes max X %u\n", + DBG (DBG_err, "Top X (%u) + pixels X (%u) exceeds max X %u\n", top_x, pixels_x, max_pixels_x_current_dpi); return SANE_STATUS_INVAL; } if (top_y + pixels_y > max_pixels_y_current_dpi) { - DBG (DBG_err, "Top Y (%u) + pixels Y (%u) exceedes max Y %u\n", + DBG (DBG_err, "Top Y (%u) + pixels Y (%u) exceeds max Y %u\n", top_y, pixels_y, max_pixels_y_current_dpi); return SANE_STATUS_INVAL; } @@ -1628,7 +1628,7 @@ hp5590_read_image_params (SANE_Int dn, struct image_params image_params; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (image_params) == 16); @@ -1676,7 +1676,7 @@ hp5590_set_scan_params (SANE_Int dn, unsigned int base_dpi; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (scanner_info != NULL); hp5590_cmds_assert (dpi != 0); @@ -1754,7 +1754,7 @@ hp5590_send_reverse_calibration_map (SANE_Int dn, unsigned int len; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); DBG (DBG_proc, "Preparing reverse calibration map\n"); val = 0xffff; len = reverse_map_size / 4; @@ -1805,7 +1805,7 @@ hp5590_send_forward_calibration_maps (SANE_Int dn, unsigned int i; uint16_t val; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); DBG (DBG_proc, "Preparing forward calibration map\n"); val = 0x0000; for (i = 0; i < forward_map_size; i++) @@ -1852,7 +1852,7 @@ hp5590_read (SANE_Int dn, { SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (bytes != NULL); hp5590_cmds_assert (state != NULL); @@ -1872,7 +1872,7 @@ hp5590_start_scan (SANE_Int dn, uint8_t reg_051b = 0x40; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (sizeof (reg_051b) == 1); @@ -1897,7 +1897,7 @@ hp5590_read_buttons (SANE_Int dn, uint16_t button_status; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); hp5590_cmds_assert (status != NULL); hp5590_cmds_assert (sizeof (button_status) == 2); diff --git a/backend/hp5590_low.c b/backend/hp5590_low.c index 51da01a..4961fd7 100644 --- a/backend/hp5590_low.c +++ b/backend/hp5590_low.c @@ -143,7 +143,7 @@ hp5590_get_ack (SANE_Int dn, if (proto_flags & PF_NO_USB_IN_USB_ACK) return SANE_STATUS_GOOD; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); /* Check if USB-in-USB operation was accepted */ ret = sanei_usb_control_msg (dn, USB_DIR_IN | USB_TYPE_VENDOR, @@ -152,17 +152,17 @@ hp5590_get_ack (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error getting acknowledge\n", - __FUNCTION__); + __func__); return ret; } - DBG (DBG_usb, "%s: USB-in-USB: accepted\n", __FUNCTION__); + DBG (DBG_usb, "%s: USB-in-USB: accepted\n", __func__); /* Check if we received correct acknowledgement */ if (status != 0x01) { DBG (DBG_err, "%s: USB-in-USB: not accepted (status %u)\n", - __FUNCTION__, status); + __func__, status); return SANE_STATUS_DEVICE_BUSY; } @@ -186,7 +186,7 @@ hp5590_get_status (SANE_Int dn, uint8_t status; SANE_Status ret; - DBG (DBG_proc, "%s\n", __FUNCTION__); + DBG (DBG_proc, "%s\n", __func__); ret = sanei_usb_control_msg (dn, USB_DIR_IN | USB_TYPE_VENDOR, 0x0c, 0x8e, 0x00, @@ -194,7 +194,7 @@ hp5590_get_status (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error getting device status\n", - __FUNCTION__); + __func__); return ret; } @@ -202,7 +202,7 @@ hp5590_get_status (SANE_Int dn, if (status != 0x00) { DBG (DBG_err, "%s: USB-in-USB: got non-zero device status (status %u)\n", - __FUNCTION__, status); + __func__, status); return SANE_STATUS_DEVICE_BUSY; } @@ -244,7 +244,7 @@ hp5590_control_msg (SANE_Int dn, unsigned int needed_response; DBG (DBG_proc, "%s: USB-in-USB: core data: %s\n", - __FUNCTION__, core_flags & CORE_DATA ? "yes" : "no"); + __func__, core_flags & CORE_DATA ? "yes" : "no"); hp5590_low_assert (bytes != NULL); @@ -259,7 +259,7 @@ hp5590_control_msg (SANE_Int dn, ctrl.wIndex = htons (index); ctrl.wLength = htole16 (size); - DBG (DBG_usb, "%s: USB-in-USB: sending control msg\n", __FUNCTION__); + DBG (DBG_usb, "%s: USB-in-USB: sending control msg\n", __func__); /* Send USB-in-USB control message */ ret = sanei_usb_control_msg (dn, USB_DIR_OUT | USB_TYPE_VENDOR, 0x04, 0x8f, 0x00, @@ -267,7 +267,7 @@ hp5590_control_msg (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error sending control message\n", - __FUNCTION__); + __func__); return ret; } @@ -292,7 +292,7 @@ hp5590_control_msg (SANE_Int dn, 0x90, 0x00, next_packet_size, ptr); if (ret != SANE_STATUS_GOOD) { - DBG (DBG_err, "%s: USB-in-USB: error reading data\n", __FUNCTION__); + DBG (DBG_err, "%s: USB-in-USB: error reading data\n", __func__); return ret; } @@ -308,7 +308,7 @@ hp5590_control_msg (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error confirming data reception\n", - __FUNCTION__); + __func__); return -1; } @@ -329,7 +329,7 @@ hp5590_control_msg (SANE_Int dn, ctrl.wIndex = htons (index); ctrl.wLength = htole16 (size); - DBG (DBG_usb, "%s: USB-in-USB: sending control msg\n", __FUNCTION__); + DBG (DBG_usb, "%s: USB-in-USB: sending control msg\n", __func__); /* Send USB-in-USB control message */ ret = sanei_usb_control_msg (dn, USB_DIR_OUT | USB_TYPE_VENDOR, 0x04, 0x8f, 0x00, @@ -337,7 +337,7 @@ hp5590_control_msg (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error sending control message\n", - __FUNCTION__); + __func__); return ret; } @@ -362,7 +362,7 @@ hp5590_control_msg (SANE_Int dn, 0x8f, 0x00, next_packet_size, ptr); if (ret != SANE_STATUS_GOOD) { - DBG (DBG_err, "%s: USB-in-USB: error sending data\n", __FUNCTION__); + DBG (DBG_err, "%s: USB-in-USB: error sending data\n", __func__); return ret; } @@ -389,13 +389,13 @@ hp5590_control_msg (SANE_Int dn, } /* Getting response after data transmission */ - DBG (DBG_usb, "%s: USB-in-USB: getting response\n", __FUNCTION__); + DBG (DBG_usb, "%s: USB-in-USB: getting response\n", __func__); ret = sanei_usb_control_msg (dn, USB_DIR_IN | USB_TYPE_VENDOR, 0x0c, 0x90, 0x00, sizeof (response), &response); if (ret != SANE_STATUS_GOOD) { - DBG (DBG_err, "%s: USB-in-USB: error getting response\n", __FUNCTION__); + DBG (DBG_err, "%s: USB-in-USB: error getting response\n", __func__); return ret; } @@ -405,14 +405,14 @@ hp5590_control_msg (SANE_Int dn, needed_response = core_flags & CORE_BULK_OUT ? 0x24 : 0x00; if (response == needed_response) DBG (DBG_usb, "%s: USB-in-USB: got correct response\n", - __FUNCTION__); + __func__); if (response != needed_response) { DBG (DBG_err, "%s: USB-in-USB: invalid response received " "(needed %04x, got %04x)\n", - __FUNCTION__, needed_response, response); + __func__, needed_response, response); return SANE_STATUS_IO_ERROR; } @@ -421,7 +421,7 @@ hp5590_control_msg (SANE_Int dn, { uint8_t bulk_flags = 0x24; DBG (DBG_usb, "%s: USB-in-USB: sending bulk flags\n", - __FUNCTION__); + __func__); ret = sanei_usb_control_msg (dn, USB_DIR_OUT | USB_TYPE_VENDOR, 0x0c, 0x83, 0x00, @@ -429,7 +429,7 @@ hp5590_control_msg (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error sending bulk flags\n", - __FUNCTION__); + __func__); return ret; } @@ -467,7 +467,7 @@ hp5590_verify_last_cmd (SANE_Int dn, SANE_Status ret; DBG (3, "%s: USB-in-USB: command verification requested\n", - __FUNCTION__); + __func__); /* Read last command along with CORE status */ ret = hp5590_control_msg (dn, @@ -489,17 +489,17 @@ hp5590_verify_last_cmd (SANE_Int dn, /* Verify last command */ DBG (DBG_usb, "%s: USB-in-USB: command verification %04x, " "last command: %04x, core status: %04x\n", - __FUNCTION__, verify_cmd, last_cmd, core_status); + __func__, verify_cmd, last_cmd, core_status); if ((cmd & 0x00ff) != last_cmd) { DBG (DBG_err, "%s: USB-in-USB: command verification failed: " "expected 0x%04x, got 0x%04x\n", - __FUNCTION__, cmd, last_cmd); + __func__, cmd, last_cmd); return SANE_STATUS_IO_ERROR; } DBG (DBG_usb, "%s: USB-in-USB: command verified successfully\n", - __FUNCTION__); + __func__); /* Return value depends on CORE status */ return core_status & CORE_FLAG_NOT_READY ? @@ -534,7 +534,7 @@ hp5590_cmd (SANE_Int dn, { SANE_Status ret; - DBG (3, "%s: USB-in-USB: command : %04x\n", __FUNCTION__, cmd); + DBG (3, "%s: USB-in-USB: command : %04x\n", __func__, cmd); ret = hp5590_control_msg (dn, proto_flags, @@ -568,7 +568,7 @@ hp5590_low_init_bulk_read_state (void **state) { struct bulk_read_state *bulk_read_state; - DBG (3, "%s: USB-in-USB: initializing bulk read state\n", __FUNCTION__); + DBG (3, "%s: USB-in-USB: initializing bulk read state\n", __func__); hp5590_low_assert (state != NULL); @@ -582,7 +582,7 @@ hp5590_low_init_bulk_read_state (void **state) if (!bulk_read_state->buffer) { DBG (DBG_err, "%s: Memory allocation failed for %u bytes\n", - __FUNCTION__, ALLOCATE_BULK_READ_PAGES * BULK_READ_PAGE_SIZE); + __func__, ALLOCATE_BULK_READ_PAGES * BULK_READ_PAGE_SIZE); return SANE_STATUS_NO_MEM; } bulk_read_state->buffer_size = ALLOCATE_BULK_READ_PAGES @@ -613,7 +613,7 @@ hp5590_low_free_bulk_read_state (void **state) { struct bulk_read_state *bulk_read_state; - DBG (3, "%s\n", __FUNCTION__); + DBG (3, "%s\n", __func__); hp5590_low_assert (state != NULL); /* Just return if NULL bulk read state was given */ @@ -622,7 +622,7 @@ hp5590_low_free_bulk_read_state (void **state) bulk_read_state = *state; - DBG (3, "%s: USB-in-USB: freeing bulk read state\n", __FUNCTION__); + DBG (3, "%s: USB-in-USB: freeing bulk read state\n", __func__); free (bulk_read_state->buffer); bulk_read_state->buffer = NULL; @@ -656,7 +656,7 @@ hp5590_bulk_read (SANE_Int dn, struct bulk_read_state *bulk_read_state; unsigned int bytes_until_buffer_end; - DBG (3, "%s\n", __FUNCTION__); + DBG (3, "%s\n", __func__); hp5590_low_assert (state != NULL); hp5590_low_assert (bytes != NULL); @@ -665,7 +665,7 @@ hp5590_bulk_read (SANE_Int dn, if (bulk_read_state->initialized == 0) { DBG (DBG_err, "%s: USB-in-USB: bulk read state not initialized\n", - __FUNCTION__); + __func__); return SANE_STATUS_INVAL; } @@ -685,7 +685,7 @@ hp5590_bulk_read (SANE_Int dn, { DBG (DBG_usb, "%s: USB-in-USB: not enough data in buffer available " "(available: %u, requested: %u)\n", - __FUNCTION__, bulk_read_state->bytes_available, size); + __func__, bulk_read_state->bytes_available, size); /* IMPORTANT! 'next_pages' means 'request and receive next_pages pages in * one bulk transfer request '. Windows driver uses 4 pages between each @@ -703,7 +703,7 @@ hp5590_bulk_read (SANE_Int dn, */ bulk_read_state->total_pages++; DBG (DBG_usb, "%s: USB-in-USB: total pages done: %u\n", - __FUNCTION__, bulk_read_state->total_pages); + __func__, bulk_read_state->total_pages); /* Send another bulk request for 'next_pages' before first * page or next necessary one @@ -713,7 +713,7 @@ hp5590_bulk_read (SANE_Int dn, { /* Send bulk flags */ DBG (DBG_usb, "%s: USB-in-USB: sending USB-in-USB bulk flags\n", - __FUNCTION__); + __func__); bulk_flags = 0x24; ret = sanei_usb_control_msg (dn, USB_DIR_OUT | USB_TYPE_VENDOR, 0x0c, 0x83, 0x00, @@ -721,7 +721,7 @@ hp5590_bulk_read (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error sending bulk flags\n", - __FUNCTION__); + __func__); return ret; } @@ -738,7 +738,7 @@ hp5590_bulk_read (SANE_Int dn, /* Send bulk read request */ DBG (DBG_usb, "%s: USB-in-USB: sending control msg for bulk\n", - __FUNCTION__); + __func__); ret = sanei_usb_control_msg (dn, USB_DIR_OUT | USB_TYPE_VENDOR, 0x04, 0x82, 0x00, sizeof (ctrl), @@ -746,7 +746,7 @@ hp5590_bulk_read (SANE_Int dn, if (ret != SANE_STATUS_GOOD) { DBG (DBG_err, "%s: USB-in-USB: error sending control msg\n", - __FUNCTION__); + __func__); return ret; } @@ -761,13 +761,13 @@ hp5590_bulk_read (SANE_Int dn, if (bulk_read_state->buffer_size - bulk_read_state->bytes_available < next_portion) { - DBG (DBG_err, "%s: USB-in-USB: buffer too small\n", __FUNCTION__); + DBG (DBG_err, "%s: USB-in-USB: buffer too small\n", __func__); return SANE_STATUS_NO_MEM; } /* Bulk read next page */ DBG (DBG_usb, "%s: USB-in-USB: bulk reading %lu bytes\n", - __FUNCTION__, (u_long) next_portion); + __func__, (u_long) next_portion); ret = sanei_usb_read_bulk (dn, bulk_read_state->buffer_in_ptr, &next_portion); @@ -776,7 +776,7 @@ hp5590_bulk_read (SANE_Int dn, if (ret == SANE_STATUS_EOF) return ret; DBG (DBG_err, "%s: USB-in-USB: error during bulk read: %s\n", - __FUNCTION__, sane_strstatus (ret)); + __func__, sane_strstatus (ret)); return ret; } @@ -785,7 +785,7 @@ hp5590_bulk_read (SANE_Int dn, { DBG (DBG_err, "%s: USB-in-USB: incomplete bulk read " "(requested %u bytes, got %lu bytes)\n", - __FUNCTION__, BULK_READ_PAGE_SIZE, (u_long) next_portion); + __func__, BULK_READ_PAGE_SIZE, (u_long) next_portion); return SANE_STATUS_IO_ERROR; } @@ -798,7 +798,7 @@ hp5590_bulk_read (SANE_Int dn, DBG (DBG_err, "%s: USB-in-USB: attempted to access over the end of buffer " "(in_ptr: %p, end_ptr: %p, ptr: %p, buffer size: %u\n", - __FUNCTION__, bulk_read_state->buffer_in_ptr, + __func__, bulk_read_state->buffer_in_ptr, bulk_read_state->buffer_end_ptr, bulk_read_state->buffer, bulk_read_state->buffer_size); return SANE_STATUS_NO_MEM; @@ -808,7 +808,7 @@ hp5590_bulk_read (SANE_Int dn, if (bulk_read_state->buffer_in_ptr == bulk_read_state->buffer_end_ptr) { DBG (DBG_usb, "%s: USB-in-USB: buffer wrapped while writing\n", - __FUNCTION__); + __func__); bulk_read_state->buffer_in_ptr = bulk_read_state->buffer; } @@ -819,7 +819,7 @@ hp5590_bulk_read (SANE_Int dn, /* Transfer requested amount of data to the caller */ DBG (DBG_usb, "%s: USB-in-USB: data in bulk buffer is available " "(requested %u bytes, available %u bytes)\n", - __FUNCTION__, size, bulk_read_state->bytes_available); + __func__, size, bulk_read_state->bytes_available); /* Check for buffer pointer wrapping */ bytes_until_buffer_end = bulk_read_state->buffer_end_ptr @@ -827,13 +827,13 @@ hp5590_bulk_read (SANE_Int dn, if (bytes_until_buffer_end <= size) { /* First buffer part */ - DBG (DBG_usb, "%s: USB-in-USB: reached bulk read buffer end\n", __FUNCTION__); + DBG (DBG_usb, "%s: USB-in-USB: reached bulk read buffer end\n", __func__); memcpy (bytes, bulk_read_state->buffer_out_ptr, bytes_until_buffer_end); bulk_read_state->buffer_out_ptr = bulk_read_state->buffer; /* And second part (if any) */ if (bytes_until_buffer_end < size) { - DBG (DBG_usb, "%s: USB-in-USB: giving 2nd buffer part\n", __FUNCTION__); + DBG (DBG_usb, "%s: USB-in-USB: giving 2nd buffer part\n", __func__); memcpy (bytes + bytes_until_buffer_end, bulk_read_state->buffer_out_ptr, size - bytes_until_buffer_end); @@ -848,7 +848,7 @@ hp5590_bulk_read (SANE_Int dn, if (bulk_read_state->buffer_out_ptr == bulk_read_state->buffer_end_ptr) { DBG (DBG_usb, "%s: USB-in-USB: buffer wrapped while reading\n", - __FUNCTION__); + __func__); bulk_read_state->buffer_out_ptr = bulk_read_state->buffer; } } @@ -886,7 +886,7 @@ hp5590_bulk_write (SANE_Int dn, unsigned char *ptr; size_t next_portion; - DBG (3, "%s: USB-in-USB: command: %04x, size %u\n", __FUNCTION__, cmd, + DBG (3, "%s: USB-in-USB: command: %04x, size %u\n", __func__, cmd, size); hp5590_low_assert (bytes != NULL); @@ -898,7 +898,7 @@ hp5590_bulk_write (SANE_Int dn, /* Send bulk write request */ DBG (3, "%s: USB-in-USB: total %u pages (each of %u bytes)\n", - __FUNCTION__, bulk_size.size, BULK_WRITE_PAGE_SIZE); + __func__, bulk_size.size, BULK_WRITE_PAGE_SIZE); ret = hp5590_control_msg (dn, proto_flags, USB_DIR_OUT, @@ -919,7 +919,7 @@ hp5590_bulk_write (SANE_Int dn, next_portion = len; DBG (3, "%s: USB-in-USB: next portion %lu bytes\n", - __FUNCTION__, (u_long) next_portion); + __func__, (u_long) next_portion); /* Prepare bulk write request */ memset (&ctrl, 0, sizeof (ctrl)); @@ -941,7 +941,7 @@ hp5590_bulk_write (SANE_Int dn, /* Write bulk data */ DBG (3, "%s: USB-in-USB: bulk writing %lu bytes\n", - __FUNCTION__, (u_long) next_portion); + __func__, (u_long) next_portion); ret = sanei_usb_write_bulk (dn, ptr, &next_portion); if (ret != SANE_STATUS_GOOD) { @@ -949,7 +949,7 @@ hp5590_bulk_write (SANE_Int dn, if (ret == SANE_STATUS_EOF) break; DBG (DBG_err, "%s: USB-in-USB: error during bulk write: %s\n", - __FUNCTION__, sane_strstatus (ret)); + __func__, sane_strstatus (ret)); return ret; } diff --git a/backend/hpsj5s.c b/backend/hpsj5s.c index 75f3526..9c6ad79 100644 --- a/backend/hpsj5s.c +++ b/backend/hpsj5s.c @@ -161,7 +161,6 @@ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char line[PATH_MAX]; /*Line from config file */ - int len; /*Length of string from config file */ FILE *config_file; /*Handle to config file of this backend */ DBG_INIT (); @@ -189,7 +188,6 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { if ((line[0] == '#') || (line[0] == '\0')) /*comment line or empty line */ continue; - len = strlen (line); /*sanei_config_read guaranty, it's not more then PATH_MAX-1 */ strcpy (scanner_path, line); /*so, we choose last in file (uncommented) */ } diff --git a/backend/hs2p-saneopts.h b/backend/hs2p-saneopts.h index 7ea50c2..0e712a3 100644 --- a/backend/hs2p-saneopts.h +++ b/backend/hs2p-saneopts.h @@ -110,7 +110,7 @@ #define SANE_NAME_BARCODE_HMIN "barcode-hmin" #define SANE_TITLE_BARCODE_HMIN "Barcode Minimum Height" -#define SANE_DESC_BARCODE_HMIN "Sets the Barcode Minimun Height (larger values increase recognition speed)" +#define SANE_DESC_BARCODE_HMIN "Sets the Barcode Minimum Height (larger values increase recognition speed)" #define SANE_NAME_BARCODE_SEARCH_MODE "barcode-search-mode" #define SANE_TITLE_BARCODE_SEARCH_MODE "Barcode Search Mode" diff --git a/backend/hs2p-scsi.c b/backend/hs2p-scsi.c index a14e6cb..431ba9d 100644 --- a/backend/hs2p-scsi.c +++ b/backend/hs2p-scsi.c @@ -373,7 +373,7 @@ print_sense_data (int dbg_level, SENSE_DATA * data) (data->sense_key & 0x0F)); DBG (dbg_level, "Information Byte = %lu\n", _4btol (data->information)); DBG (dbg_level, "Additional Sense Length = %d\n", data->sense_length); - DBG (dbg_level, "Command Specific Infomation = %lu\n", + DBG (dbg_level, "Command Specific Information = %lu\n", _4btol (data->command_specific_information)); DBG (dbg_level, "Additional Sense Code = %#x\n", data->sense_code); DBG (dbg_level, "Additional Sense Code Qualifier = %#x\n", diff --git a/backend/kodak.c b/backend/kodak.c index 80a5700..73243db 100644 --- a/backend/kodak.c +++ b/backend/kodak.c @@ -1,5 +1,12 @@ /* sane - Scanner Access Now Easy. + This file is part of the SANE package, and implements a SANE backend + for various large Kodak scanners. + + Copyright (C) 2008-2010 m. allan noah + + -------------------------------------------------------------------------- + This file is part of the SANE package. This program is free software; you can redistribute it and/or @@ -40,8 +47,6 @@ -------------------------------------------------------------------------- - This file implements a SANE backend for various large Kodak scanners. - The source code is divided in sections which you can easily find by searching for the tag "@@". @@ -2749,7 +2754,6 @@ do_cmd(struct scanner *s, int runRS, int shortTime, ) { SANE_Status ret = SANE_STATUS_GOOD; - size_t actLen = 0; /*shut up compiler*/ runRS=runRS; @@ -2766,7 +2770,6 @@ do_cmd(struct scanner *s, int runRS, int shortTime, } if (inBuff && inLen){ DBG(25, "in: reading %d bytes\n", (int)*inLen); - actLen = *inLen; } ret = sanei_scsi_cmd2(s->fd, cmdBuff, cmdLen, outBuff, outLen, inBuff, inLen); diff --git a/backend/kodakaio.c b/backend/kodakaio.c index 42b59a5..a9bec7b 100644 --- a/backend/kodakaio.c +++ b/backend/kodakaio.c @@ -1,7 +1,7 @@ /* * kodakaio.c - SANE library for Kodak ESP Aio scanners. * - * Copyright (C) 2011-2015 Paul Newall + * Copyright (C) 2011-2017 Paul Newall * * Based on the Magicolor sane backend: * Based on the epson2 sane backend: @@ -19,6 +19,7 @@ * 01/01/13 Now with adf, the scan can be padded to make up the full page length, * or the page can terminate at the end of the paper. This is a selectable option. * 25/11/12 Using avahi now for net autodiscovery. Use configure option --enable-avahi + * 1/5/17 patched to use local pointer for avahi callback */ /* @@ -31,13 +32,13 @@ convenient lines to paste export SANE_DEBUG_KODAKAIO=20 for ubuntu prior to 12.10 -./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-avahi --disable-latex BACKENDS="kodakaio test" +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-avahi --without-api-spec BACKENDS="kodakaio test" for ubuntu 12.10 -./configure --prefix=/usr --libdir=/usr/lib/i386-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --disable-latex BACKENDS="kodakaio test" +./configure --prefix=/usr --libdir=/usr/lib/i386-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --without-api-spec BACKENDS="kodakaio test" -for ubuntu 14.10 -./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --disable-latex BACKENDS="kodakaio test" +for ubuntu 14.10 up to at least 17.04 +./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --without-api-spec BACKENDS="kodakaio test" If you want to use the test backend, for example with sane-troubleshoot, you should enable it in /etc/sane.d/dll.conf @@ -153,7 +154,7 @@ If you want to use the test backend, for example with sane-troubleshoot, you sho #define KODAKAIO_VERSION 02 #define KODAKAIO_REVISION 7 -#define KODAKAIO_BUILD 2 +#define KODAKAIO_BUILD 3 /* for usb (but also used for net though it's not required). */ #define MAX_BLOCK_SIZE 32768 @@ -207,6 +208,7 @@ normal levels. This system is a plan rather than a reality #include #include #include +#include #if WITH_AVAHI /* used for auto detecting network printers */ @@ -216,9 +218,6 @@ normal levels. This system is a plan rather than a reality #include #include #include - -static AvahiSimplePoll *simple_poll = NULL; /* global because called by several functions */ - #endif #include "../include/sane/saneopts.h" @@ -639,8 +638,10 @@ static SANE_Status attach_one_usb(SANE_String_Const devname); static SANE_Status attach_one_net(SANE_String_Const devname, unsigned int device); void kodakaio_com_str(unsigned char *buf, char *fmt_buf); int cmparray (unsigned char *array1, unsigned char *array2, size_t len); +#if WITH_AVAHI static struct KodakaioCap *get_device_from_identification (const char *ident, const char *vid, const char *pid); void ProcessAvahiDevice(const char *device_id, const char *vid, const char *pid, const char *ip_addr); +#endif /* Some utility functions */ @@ -731,7 +732,7 @@ That is probably if the scanner disconnected the network connection if (read == 0) *status = SANE_STATUS_IO_ERROR; - DBG(32, "net read %d bytes:%x,%x,%x,%x,%x,%x,%x,%x\n",read,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]); + DBG(32, "net read %lu bytes:%x,%x,%x,%x,%x,%x,%x,%x\n",(unsigned long)read,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]); return read; } @@ -881,7 +882,7 @@ In NET mode the timeout is in kodakaio_net_read time(&time_start); DBG(min(16,DBG_READ), "[%ld] %s: net req size = %ld ", (long) time_start, __func__, (long) buf_size); n = kodakaio_net_read(s, buf, buf_size, status); - DBG(min(16,DBG_READ), "returned %d\n", n); + DBG(min(16,DBG_READ), "returned %lu\n", (unsigned long)n); if (*status != SANE_STATUS_GOOD) { DBG(1, "%s: err returned from kodakaio_net_read, %s\n", __func__, sane_strstatus(*status)); } @@ -1109,7 +1110,7 @@ cmd_start_scan (SANE_Handle handle, size_t expect_total) return SANE_STATUS_IO_ERROR; } - DBG(20, "starting the scan, expected total bytes %d\n",expect_total); + DBG(20, "starting the scan, expected total bytes %lu\n",(unsigned long)expect_total); k_send(s, KodakEsp_Go, 8, &status); if (status != SANE_STATUS_GOOD) @@ -1365,25 +1366,25 @@ But it seems that the scanner takes care of that, and gives you the ack as a sep /* only compare 4 bytes because we sometimes get escSS02.. or escSS00.. is 4 the right number ? */ if (cmparray(Last8,KodakEsp_Ack,4) == 0) { - DBG(min(10,DBG_READ), "%s: found KodakEsp_Ack at %d bytes of %d\n", __func__, bytecount, *len); + DBG(min(10,DBG_READ), "%s: found KodakEsp_Ack at %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); s->ack = SANE_TRUE; *len = bytecount - 8; /* discard the Ack response */ s->bytes_unread -= *len; /* return a short block */ } else { /* a not full buffer is returned usb does this */ - DBG(min(10,DBG_READ), "%s: buffer not full, got %d bytes of %d\n", __func__, bytecount, *len); + DBG(min(10,DBG_READ), "%s: buffer not full, got %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); *len = bytecount; s->bytes_unread -= bytecount; } } else { - DBG(min(1,DBG_READ), "%s: tiny read, got %d bytes of %d\n", __func__, (int) bytecount, *len); + DBG(min(1,DBG_READ), "%s: tiny read, got %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); return SANE_STATUS_IO_ERROR; } - if (*len > s->params.bytes_per_line) { + lines = *len / s->params.bytes_per_line; + if (lines > 1) { /* store average colour as background. That's not the ideal method but it's easy to implement. What's it used for? */ - lines = *len / s->params.bytes_per_line; s->background[0] = 0; s->background[1] = 0; s->background[2] = 0; @@ -1934,17 +1935,18 @@ you don't know how many blocks there will be in advance because their size may b * SANE API implementation (high-level functions) */ +#if WITH_AVAHI static struct KodakaioCap * get_device_from_identification (const char *ident, const char *vid, const char *pid) { int n; SANE_Word pidnum, vidnum; - if(sscanf(vid, "%x", &vidnum) == EOF) { + if(sscanf(vid, "%x", (unsigned int *)&vidnum) == EOF) { DBG(5, "could not convert hex vid <%s>\n", vid); return NULL; } - if(sscanf(pid, "%x", &pidnum) == EOF) { + if(sscanf(pid, "%x", (unsigned int *)&pidnum) == EOF) { DBG(5, "could not convert hex pid <%s>\n", pid); return NULL; } @@ -1965,6 +1967,7 @@ get_device_from_identification (const char *ident, const char *vid, const char * } return NULL; } +#endif /* WITH_AVAHI */ /* * close_scanner() @@ -2359,9 +2362,9 @@ static void browse_callback( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { + AvahiSimplePoll *simple_poll = userdata; - AvahiClient *c = userdata; - assert(b); + AvahiClient *c = avahi_service_browser_get_client (b); /* Called whenever a new services becomes available on the LAN or is removed from the LAN */ switch (event) { @@ -2395,7 +2398,8 @@ static void browse_callback( } } -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { +static void client_callback(AvahiClient *c, AvahiClientState state, void * userdata) { + AvahiSimplePoll *simple_poll = userdata; assert(c); /* Called whenever the client or server state changes */ @@ -2412,6 +2416,7 @@ kodak_network_discovery(const char*host) /* If host = NULL do autodiscovery. If host != NULL try to verify the model First version only does autodiscovery */ { + AvahiSimplePoll *simple_poll; AvahiClient *client = NULL; AvahiServiceBrowser *sb = NULL; int error; @@ -2427,7 +2432,7 @@ First version only does autodiscovery */ } /* Allocate a new client */ - client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error); + client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, simple_poll, &error); /* Check wether creating the client object succeeded */ if (!client) { @@ -2436,14 +2441,15 @@ First version only does autodiscovery */ } /* Create the service browser */ - if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_scanner._tcp", NULL, 0, browse_callback, client))) { + if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_scanner._tcp", NULL, 0, browse_callback, simple_poll))) { DBG(min(1,DBG_AUTO), "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client))); goto fail; } /* Run the main loop */ for(i=1;iname, devname)) diff --git a/backend/kvs20xx.h b/backend/kvs20xx.h index 9bc833d..442f1c7 100644 --- a/backend/kvs20xx.h +++ b/backend/kvs20xx.h @@ -168,6 +168,12 @@ swap_bytes32 (u32 x) (x & (u32) 0x0000ff00UL) << 8 | (x & (u32) 0x00ff0000UL) >> 8; } +static inline void +copy16 (u8 * p, u16 x) +{ + memcpy (p, (u8 *) &x, sizeof (x)); +} + #if __BYTE_ORDER == __BIG_ENDIAN static inline void set24 (u8 * p, u32 x) diff --git a/backend/kvs20xx_cmd.c b/backend/kvs20xx_cmd.c index 7579701..d0f18ee 100644 --- a/backend/kvs20xx_cmd.c +++ b/backend/kvs20xx_cmd.c @@ -187,7 +187,7 @@ kvs20xx_set_timeout (struct scanner * s, int timeout) }; c.cmd[0] = SET_TIMEOUT; c.cmd[2] = 0x8d; - *((u16 *) (c.cmd + 7)) = cpu2be16 (sizeof (t)); + copy16 (c.cmd + 7, cpu2be16 (sizeof (t))); c.data = &t; c.data_size = sizeof (t); @@ -210,7 +210,7 @@ kvs20xx_set_window (struct scanner * s, int wnd_id) CMD_OUT }; c.cmd[0] = SET_WINDOW; - *((u16 *) (c.cmd + 7)) = cpu2be16 (sizeof (wnd)); + copy16 (c.cmd + 7, cpu2be16 (sizeof (wnd))); c.data = &wnd; c.data_size = sizeof (wnd); @@ -301,29 +301,6 @@ kvs20xx_read_picture_element (struct scanner * s, unsigned side, return SANE_STATUS_GOOD; } -static SANE_Status -get_buffer_status (struct scanner * s, unsigned *data_avalible) -{ - SANE_Status status; - struct cmd c = { - {0}, - 10, - 0, - 12, - CMD_IN - }; - u32 *data; - c.cmd[0] = GET_BUFFER_STATUS; - c.cmd[7] = 12; - - status = send_command (s, &c); - if (status) - return status; - data = (u32 *) c.data; - *data_avalible = be2cpu32 (data[3]); - return SANE_STATUS_GOOD; -} - SANE_Status kvs20xx_read_image_data (struct scanner * s, unsigned page, unsigned side, void *buf, unsigned max_size, unsigned *size) diff --git a/backend/kvs20xx_cmd.h b/backend/kvs20xx_cmd.h index c18b754..4acaf62 100644 --- a/backend/kvs20xx_cmd.h +++ b/backend/kvs20xx_cmd.h @@ -9,6 +9,10 @@ Panasonic KV-S20xx USB-SCSI scanners. */ +#ifdef HAVE_SYS_TYPES_H +#include +#endif + #define COMMAND_BLOCK 1 #define DATA_BLOCK 2 #define RESPONSE_BLOCK 3 diff --git a/backend/kvs20xx_opt.c b/backend/kvs20xx_opt.c index 83d3385..94c4133 100644 --- a/backend/kvs20xx_opt.c +++ b/backend/kvs20xx_opt.c @@ -23,6 +23,7 @@ #include "kvs20xx.h" #include "kvs20xx_cmd.h" +#include static size_t max_string_size (SANE_String_Const strings[]) diff --git a/backend/kvs40xx.h b/backend/kvs40xx.h index fa17163..7fdebe6 100644 --- a/backend/kvs40xx.h +++ b/backend/kvs40xx.h @@ -10,6 +10,9 @@ #include "../include/sane/config.h" #include +#ifdef HAVE_SYS_TYPES_H +#include +#endif #undef BACKEND_NAME #define BACKEND_NAME kvs40xx @@ -225,6 +228,18 @@ swap_bytes32 (u32 x) (x & (u32) 0x0000ff00UL) << 8 | (x & (u32) 0x00ff0000UL) >> 8; } +static inline void +copy16 (u8 * p, u16 x) +{ + memcpy (p, (u8 *) &x, sizeof (x)); +} + +static inline void +copy32 (u8 * p, u32 x) +{ + memcpy (p, (u8 *) &x, sizeof (x)); +} + #if WORDS_BIGENDIAN static inline void set24 (u8 * p, u32 x) diff --git a/backend/kvs40xx_cmd.c b/backend/kvs40xx_cmd.c index ade2014..52ccc38 100644 --- a/backend/kvs40xx_cmd.c +++ b/backend/kvs40xx_cmd.c @@ -360,7 +360,7 @@ kvs40xx_set_timeout (struct scanner * s, int timeout) c.data_size = sizeof (t); c.cmd[0] = SET_TIMEOUT; c.cmd[2] = 0x8d; - *((u16 *) (c.cmd + 7)) = cpu2be16 (sizeof (t)); + copy16 (c.cmd + 7, cpu2be16 (sizeof (t))); if (s->bus == USB) sanei_usb_set_timeout (timeout * 1000); @@ -379,7 +379,7 @@ kvs40xx_set_window (struct scanner * s, int wnd_id) c.data = &wnd; c.data_size = sizeof (wnd); c.cmd[0] = SET_WINDOW; - *((u16 *) (c.cmd + 7)) = cpu2be16 (sizeof (wnd)); + copy16 (c.cmd + 7, cpu2be16 (sizeof (wnd))); kvs40xx_init_window (s, &wnd, wnd_id); return send_command (s, &c); @@ -534,28 +534,6 @@ kvs40xx_read_image_data (struct scanner * s, unsigned page, unsigned side, return status; } -static SANE_Status -get_adjust_data (struct scanner * s, unsigned *dummy_length) -{ - SANE_Status status; - struct cmd c = { - {0}, 10, - NULL, 40, - CMD_IN - }; - u16 *data; - - c.cmd[0] = GET_ADJUST_DATA; - c.cmd[2] = 0x9b; - c.cmd[8] = 40; - status = send_command (s, &c); - if (status) - return status; - data = (u16 *) c.data; - *dummy_length = be2cpu16 (data[0]); - return SANE_STATUS_GOOD; -} - SANE_Status read_support_info (struct scanner * s, struct support_info * inf) { diff --git a/backend/kvs40xx_opt.c b/backend/kvs40xx_opt.c index c4f478b..bd9d85e 100644 --- a/backend/kvs40xx_opt.c +++ b/backend/kvs40xx_opt.c @@ -22,6 +22,7 @@ #include "../include/sane/sanei_debug.h" +#include static inline unsigned mm2scanner_units (unsigned mm) @@ -1271,41 +1272,45 @@ kvs40xx_init_window (struct scanner *s, struct window *wnd, int wnd_id) { int paper = str_index (paper_list, s->val[PAPER_SIZE].s), i; memset (wnd, 0, sizeof (struct window)); - *(u16 *) wnd->window_descriptor_block_length = cpu2be16 (66); + copy16 (wnd->window_descriptor_block_length, cpu2be16 (66)); wnd->window_identifier = wnd_id; - *(u16 *) wnd->x_resolution = cpu2be16 (s->val[RESOLUTION].w); - *(u16 *) wnd->y_resolution = cpu2be16 (s->val[RESOLUTION].w); + copy16 (wnd->x_resolution, cpu2be16 (s->val[RESOLUTION].w)); + copy16 (wnd->y_resolution, cpu2be16 (s->val[RESOLUTION].w)); if (!paper) { - *(u32 *) wnd->upper_left_x = - cpu2be32 (mm2scanner_units (s->val[TL_X].w)); - *(u32 *) wnd->upper_left_y = - cpu2be32 (mm2scanner_units (s->val[TL_Y].w)); - *(u32 *) wnd->document_width = - cpu2be32 (mm2scanner_units (s->val[BR_X].w)); - *(u32 *) wnd->width = - cpu2be32 (mm2scanner_units (s->val[BR_X].w - s->val[TL_X].w)); - *(u32 *) wnd->document_length = cpu2be32 (mm2scanner_units - (s->val[BR_Y].w)); - *(u32 *) wnd->length = - cpu2be32 (mm2scanner_units (s->val[BR_Y].w - s->val[TL_Y].w)); + copy32 (wnd->upper_left_x, + cpu2be32 (mm2scanner_units (s->val[TL_X].w))); + copy32 (wnd->upper_left_y, + cpu2be32 (mm2scanner_units (s->val[TL_Y].w))); + copy32 (wnd->document_width, + cpu2be32 (mm2scanner_units (s->val[BR_X].w))); + copy32 (wnd->width, + cpu2be32 (mm2scanner_units (s->val[BR_X].w - s->val[TL_X].w))); + copy32 (wnd->document_length, cpu2be32 (mm2scanner_units + (s->val[BR_Y].w))); + copy32 (wnd->length, + cpu2be32 (mm2scanner_units (s->val[BR_Y].w - s->val[TL_Y].w))); } else { u32 w = cpu2be32 (mm2scanner_units (paper_sizes[paper].width)); u32 h = cpu2be32 (mm2scanner_units (paper_sizes[paper].height)); - *(u32 *) wnd->upper_left_x = cpu2be32 (mm2scanner_units (0)); - *(u32 *) wnd->upper_left_y = cpu2be32 (mm2scanner_units (0)); + copy32 (wnd->upper_left_x, cpu2be32 (mm2scanner_units (0))); + copy32 (wnd->upper_left_y, cpu2be32 (mm2scanner_units (0))); if (!s->val[LANDSCAPE].b) { - *(u32 *) wnd->document_width = *(u32 *) wnd->width = w; - *(u32 *) wnd->document_length = *(u32 *) wnd->length = h; + copy32 (wnd->width, w); + copy32 (wnd->length, h); + copy32 (wnd->document_width, w); + copy32 (wnd->document_length, h); } else { - *(u32 *) wnd->document_width = *(u32 *) wnd->width = h; - *(u32 *) wnd->document_length = *(u32 *) wnd->length = w; + copy32 (wnd->width, h); + copy32 (wnd->length, w); + copy32 (wnd->document_width, h); + copy32 (wnd->document_length, w); } } wnd->brightness = s->val[BRIGHTNESS].w; @@ -1314,11 +1319,11 @@ kvs40xx_init_window (struct scanner *s, struct window *wnd, int wnd_id) wnd->image_composition = mode_val[str_index (mode_list, s->val[MODE].s)]; wnd->bit_per_pixel = bps_val[str_index (mode_list, s->val[MODE].s)]; - *(u16 *) wnd->halftone_pattern = - cpu2be16 (str_index (halftone_pattern, s->val[HALFTONE_PATTERN].s)); + copy16 (wnd->halftone_pattern, + cpu2be16 (str_index (halftone_pattern, s->val[HALFTONE_PATTERN].s))); wnd->rif_padding = s->val[INVERSE].b << 7; - *(u16 *) wnd->bit_ordering = cpu2be16 (BIT_ORDERING); + copy16 (wnd->bit_ordering, cpu2be16 (BIT_ORDERING)); wnd->compression_type = s->val[COMPRESSION].b ? 0x81 : 0; wnd->compression_argument = s->val[COMPRESSION_PAR].w; diff --git a/backend/lexmark_low.c b/backend/lexmark_low.c index 821b621..fe20e89 100644 --- a/backend/lexmark_low.c +++ b/backend/lexmark_low.c @@ -2369,6 +2369,9 @@ low_get_start_loc (SANE_Int resolution, SANE_Int * vert_start, return SANE_STATUS_INVAL; } break; + default: + /* If we're here we have an unknown dev->model.sensor_type */ + return SANE_STATUS_INVAL; } /* Calculate vertical start distance at 600dpi */ switch (resolution) diff --git a/backend/ma1509.c b/backend/ma1509.c index 5fccd1c..e38ddc5 100644 --- a/backend/ma1509.c +++ b/backend/ma1509.c @@ -1738,7 +1738,6 @@ sane_start (SANE_Handle handle) { Ma1509_Scanner *s = handle; SANE_Status status; - SANE_String_Const mode; struct timeval start; if (!s) @@ -1778,8 +1777,6 @@ sane_start (SANE_Handle handle) /* save start time */ gettimeofday (&start, 0); s->start_time = start.tv_sec; - /* translate options into s->mode for convenient access: */ - mode = s->val[OPT_MODE].s; status = set_window (s); if (status != SANE_STATUS_GOOD) diff --git a/backend/magicolor.c b/backend/magicolor.c index 660f517..d3af142 100644 --- a/backend/magicolor.c +++ b/backend/magicolor.c @@ -1385,7 +1385,6 @@ static SANE_Status mc_init_parameters(Magicolor_Scanner * s) { int dpi, optres; - struct mode_param *mparam; DBG(5, "%s\n", __func__); @@ -1394,8 +1393,6 @@ mc_init_parameters(Magicolor_Scanner * s) dpi = s->val[OPT_RESOLUTION].w; optres = s->hw->cap->optical_res; - mparam = &mode_params[s->val[OPT_MODE].w]; - if (SANE_UNFIX(s->val[OPT_BR_Y].w) == 0 || SANE_UNFIX(s->val[OPT_BR_X].w) == 0) return SANE_STATUS_INVAL; @@ -1521,6 +1518,7 @@ mc_read(struct Magicolor_Scanner *s) ****************************************************************************/ +#if HAVE_LIBSNMP static struct MagicolorCap * mc_get_device_from_identification (const char*ident) { @@ -1531,6 +1529,7 @@ mc_get_device_from_identification (const char*ident) } return NULL; } +#endif /* @@ -1970,10 +1969,10 @@ mc_network_discovery(const char*host) init_snmp("sane-magicolor-backend"); snmp_sess_init (&session); session.version = SNMP_VERSION_2c; - session.community = "public"; - session.community_len = strlen (session.community); + session.community = (u_char *) "public"; + session.community_len = strlen ((char *)session.community); if (host) { - session.peername = host; + session.peername = (char *) host; } else { /* Do a network discovery via a broadcast */ session.peername = "255.255.255.255"; diff --git a/backend/magicolor.h b/backend/magicolor.h index 7ea1e1e..b1195a0 100644 --- a/backend/magicolor.h +++ b/backend/magicolor.h @@ -44,13 +44,6 @@ #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" -#ifdef __GNUC__ -#define __func__ __FUNCTION__ -#else -#define __func__ "(undef)" -/* I cast my vote for C99... :) */ -#endif - /* Silence the compiler for unused arguments */ #define NOT_USED(x) ( (void)(x) ) diff --git a/backend/microtek2.c b/backend/microtek2.c index 8fdf497..dccd707 100644 --- a/backend/microtek2.c +++ b/backend/microtek2.c @@ -443,12 +443,14 @@ sane_get_select_fd (SANE_Handle handle, SANE_Int *fd) /*---------- sane_init() -----------------------------------------------------*/ SANE_Status +#ifdef HAVE_AUTHORIZATION sane_init(SANE_Int *version_code, SANE_Auth_Callback authorize) +#else +sane_init(SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize) +#endif { Microtek2_Device *md; FILE *fp; - int match; - SANE_Auth_Callback trash; DBG_INIT(); @@ -460,13 +462,10 @@ sane_init(SANE_Int *version_code, SANE_Auth_Callback authorize) #ifdef HAVE_AUTHORIZATION auth_callback = authorize; -#else - trash = authorize; /* prevents compiler warning "unused variable" */ #endif sanei_thread_init(); - match = 0; fp = sanei_config_open(MICROTEK2_CONFIG_FILE); if ( fp == NULL ) DBG(10, "sane_init: file not opened: '%s'\n", MICROTEK2_CONFIG_FILE); @@ -909,7 +908,7 @@ cancel_scan(Microtek2_Scanner *ms) of material on a feeder, then pid may be already -1 and kill(-1, SIGTERM), i.e. killing all our processes, is not likely what we really want - --mj, 2001/Nov/19 */ - if (ms->pid != -1) + if (sanei_thread_is_valid (ms->pid)) { sanei_thread_kill(ms->pid); sanei_thread_waitpid(ms->pid, NULL); @@ -1346,14 +1345,10 @@ check_inquiry(Microtek2_Device *md, SANE_String *model_string) static void cleanup_scanner(Microtek2_Scanner *ms) { - SANE_Status status; - Microtek2_Device *md; - md = ms->dev; - DBG(30, "cleanup_scanner: ms=%p, ms->sfd=%d\n", (void *) ms, ms->sfd); if ( ms->scanning == SANE_TRUE ) - status=cancel_scan(ms); + cancel_scan(ms); if ( ms->sfd != -1 ) sanei_scsi_close(ms->sfd); @@ -1616,10 +1611,9 @@ dump_area2(uint8_t *area, int len, char *info) #define BPL 16 /* bytes per line to print */ - int i, linelength; + int i; char outputline[100]; char *outbuf; - linelength = BPL * 3; if ( ! info[0] ) info = "No additional info available"; @@ -1991,7 +1985,7 @@ parse_config_file(FILE *fp, Config_Temp **ct) /*---------- signal_handler() ------------------------------------------------*/ -static RETSIGTYPE +static void signal_handler (int signal) { if ( signal == SIGTERM ) @@ -4466,15 +4460,12 @@ scsi_read_attributes(Microtek2_Info *pmi, char *device, uint8_t scan_source) static SANE_Status scsi_read_control_bits(Microtek2_Scanner *ms) { - Microtek2_Device *md; SANE_Status status; uint8_t cmd[RCB_CMD_L]; uint32_t byte; int bit; int count_1s; - md = ms->dev; - DBG(30, "scsi_read_control_bits: ms=%p, fd=%d\n", (void *) ms, ms->sfd); DBG(30, "ms->control_bytes = %p\n", ms->control_bytes); @@ -4795,7 +4786,6 @@ scsi_read_image_status(Microtek2_Scanner *ms) static SANE_Status scsi_read_shading(Microtek2_Scanner *ms, uint8_t *buffer, uint32_t length) { - Microtek2_Device *md; uint8_t cmd[RSI_CMD_L]; SANE_Bool endiantype; SANE_Status status = SANE_STATUS_GOOD; @@ -4804,8 +4794,6 @@ scsi_read_shading(Microtek2_Scanner *ms, uint8_t *buffer, uint32_t length) DBG(30, "scsi_read_shading: pos=%p, size=%d, word=%d, color=%d, dark=%d\n", buffer, length, ms->word, ms->current_color, ms->dark); - md = ms->dev; - size = length; RSI_SET_CMD(cmd); @@ -5080,7 +5068,6 @@ scsi_sense_handler (int fd, u_char *sense, void *arg) { int as_info_length; uint8_t sense_key; - uint8_t asl; uint8_t asc; uint8_t ascq; @@ -5090,7 +5077,6 @@ scsi_sense_handler (int fd, u_char *sense, void *arg) dump_area(sense, RQS_LENGTH(sense), "SenseBuffer"); sense_key = RQS_SENSEKEY(sense); - asl = RQS_ASL(sense); asc = RQS_ASC(sense); ascq = RQS_ASCQ(sense); @@ -5152,7 +5138,7 @@ scsi_sense_handler (int fd, u_char *sense, void *arg) else if ( asc == 0x3d && ascq == 0x00) DBG(5, "scsi_sense_handler: Invalid bit in IDENTIFY\n"); else if ( asc == 0x2c && ascq == 0x02 ) -/* Ok */ DBG(5, "scsi_sense_handler: Invalid comb. of windows specfied\n"); +/* Ok */ DBG(5, "scsi_sense_handler: Invalid comb. of windows specified\n"); else if ( asc == 0x20 && ascq == 0x00 ) /* Ok */ DBG(5, "scsi_sense_handler: Invalid command opcode\n"); else if ( asc == 0x24 && ascq == 0x00 ) @@ -5503,7 +5489,7 @@ sane_start(SANE_Handle handle) /* create reader routine as new thread or process */ ms->pid = sanei_thread_begin( reader_process,(void*) ms); - if ( ms->pid == -1 ) + if ( !sanei_thread_is_valid (ms->pid) ) { DBG(1, "sane_start: fork failed\n"); status = SANE_STATUS_IO_ERROR; @@ -7279,7 +7265,6 @@ chunky_proc_data(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; - Microtek2_Info *mi; uint32_t line; uint8_t *from; int pad; @@ -7292,7 +7277,6 @@ chunky_proc_data(Microtek2_Scanner *ms) DBG(30, "chunky_proc_data: ms=%p\n", (void *) ms); md = ms->dev; - mi = &md->info[md->scan_source]; bits_pp_in = ms->bits_per_pixel_in; bits_pp_out = ms->bits_per_pixel_out; pad = (int) ceil( (double) (ms->ppl * bits_pp_in) / 8.0 ) % 2; @@ -7410,7 +7394,6 @@ segreg_proc_data(Microtek2_Scanner *ms) int color; int save_current_src; int frame; - int right_to_left; DBG(30, "segreg_proc_data: ms=%p\n", (void *) ms); @@ -7420,7 +7403,6 @@ segreg_proc_data(Microtek2_Scanner *ms) pad = (int) ceil( (double) (ms->ppl * ms->bits_per_pixel_in) / 8.0 ) % 2; bpp = ms->bits_per_pixel_out / 8; /* bits_per_pixel_out is either 8 or 16 */ bpf = ms->bpl / 3; - right_to_left = mi->direction & MI_DATSEQ_RTOL; DBG(30, "segreg_proc_data: lines=%d, bpl=%d, ppl=%d, bpf=%d, bpp=%d,\n" "depth=%d, pad=%d, freelines=%d, calib_backend=%d\n", @@ -7688,7 +7670,6 @@ lplconcat_proc_data(Microtek2_Scanner *ms) uint8_t *save_from[3]; int color; int bpp; - int pad; int gamma_by_backend; int right_to_left; /* 0=left to right, 1=right to left */ @@ -7701,7 +7682,6 @@ lplconcat_proc_data(Microtek2_Scanner *ms) mi = &md->info[md->scan_source]; bpp = ms->bits_per_pixel_out / 8; /* ms->bits_per_pixel_out is 8 or 16 */ - pad = (ms->ppl * bpp) % 2; right_to_left = mi->direction & MI_DATSEQ_RTOL; gamma_by_backend = md->model_flags & MD_NO_GAMMA ? 1 : 0; diff --git a/backend/microtek2.h b/backend/microtek2.h index 4100fad..2a1f697 100644 --- a/backend/microtek2.h +++ b/backend/microtek2.h @@ -1307,7 +1307,7 @@ set_option_dependencies(Microtek2_Scanner *, static SANE_Status shading_function(Microtek2_Scanner *, uint8_t *); -static RETSIGTYPE +static void signal_handler (int); static SANE_Status diff --git a/backend/mustek.c b/backend/mustek.c index 7f0db8c..8426dfe 100644 --- a/backend/mustek.c +++ b/backend/mustek.c @@ -1669,7 +1669,7 @@ attach (SANE_String_Const devname, Mustek_Device ** devp, SANE_Bool may_wait) DBG (0, "WARNING: Your scanner was detected by the SANE Mustek backend, " "but\n it is not fully tested. It may or may not work. Be " - "carefull and read\n the PROBLEMS file in the sane directory. " + "careful and read\n the PROBLEMS file in the sane directory. " "Please set the debug level of this\n backend to maximum " "(export SANE_DEBUG_MUSTEK=255) and send the output of\n " "scanimage -L to the SANE mailing list sane-devel@lists.alioth.debian.org. " @@ -2335,16 +2335,14 @@ send_calibration_lines_se (Mustek_Scanner * s, SANE_Word color) SANE_Byte *cmd; size_t buf_size; SANE_Word column; - SANE_Word lines, bytes_per_color; + SANE_Word bytes_per_color; if (s->mode == MUSTEK_MODE_COLOR) { - lines = s->hw->cal.lines * 3; bytes_per_color = s->hw->cal.bytes / 3; } else { - lines = s->hw->cal.lines; bytes_per_color = s->hw->cal.bytes; } @@ -2952,7 +2950,7 @@ do_stop (Mustek_Scanner * s) s->scanning = SANE_FALSE; s->pass = 0; - if (s->reader_pid != -1) + if (sanei_thread_is_valid (s->reader_pid)) { SANE_Int exit_status; struct timeval now; @@ -2983,7 +2981,7 @@ do_stop (Mustek_Scanner * s) sanei_thread_kill (s->reader_pid); pid = sanei_thread_waitpid (s->reader_pid, &exit_status); - if (pid == -1) + if (!sanei_thread_is_valid (pid)) { DBG (1, "do_stop: sanei_thread_waitpid failed, already terminated? (%s)\n", @@ -4826,7 +4824,7 @@ output_data (Mustek_Scanner * s, FILE * fp, DBG (5, "output_data: end\n"); } -static RETSIGTYPE +static void sigterm_handler (int signal) { DBG (4, @@ -6565,7 +6563,7 @@ sane_start (SANE_Handle handle) /* create reader routine as new process or thread */ s->reader_pid = sanei_thread_begin (reader_process, (void *) s); - if (s->reader_pid == -1) + if (!sanei_thread_is_valid (s->reader_pid)) { DBG (1, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)); @@ -6593,7 +6591,6 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, { Mustek_Scanner *s = handle; SANE_Status status; - ssize_t ntotal; ssize_t nread; @@ -6617,7 +6614,6 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, DBG (5, "sane_read\n"); *len = 0; - ntotal = 0; if (s->cancelled) { diff --git a/backend/mustek_pp.c b/backend/mustek_pp.c index cd86bb9..9c9a533 100644 --- a/backend/mustek_pp.c +++ b/backend/mustek_pp.c @@ -237,7 +237,7 @@ do_stop(Mustek_pp_Handle *hndl) */ static int fd_to_release = 0; /*ARGSUSED*/ -static RETSIGTYPE +static void sigterm_handler (int signal __UNUSED__) { sanei_pa4s2_enable(fd_to_release, SANE_FALSE); diff --git a/backend/mustek_pp_cis.c b/backend/mustek_pp_cis.c index d5ef86d..96e89f1 100644 --- a/backend/mustek_pp_cis.c +++ b/backend/mustek_pp_cis.c @@ -1526,7 +1526,7 @@ static void cis_get_next_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf) { SANE_Byte *dest, *tmpbuf = dev->tmpbuf; - int ctr, channel, first, last, stride, ignore, step = dev->CIS.line_step; + int ctr, channel, first, last, stride, step = dev->CIS.line_step; SANE_Byte gotline; if (dev->desc->mode == MODE_COLOR) @@ -1534,14 +1534,12 @@ cis_get_next_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf) first = MUSTEK_PP_CIS_CHANNEL_RED; last = MUSTEK_PP_CIS_CHANNEL_BLUE; stride = 3; - ignore = 1; /* 1 * 3 channels */ } else { first = MUSTEK_PP_CIS_CHANNEL_GRAY; last = MUSTEK_PP_CIS_CHANNEL_GRAY; stride = 1; - ignore = 3; /* 3 * 1 channel */ } gotline = SANE_FALSE; diff --git a/backend/mustek_usb.c b/backend/mustek_usb.c index 66b1813..58dcc58 100644 --- a/backend/mustek_usb.c +++ b/backend/mustek_usb.c @@ -1572,7 +1572,7 @@ sane_cancel (SANE_Handle handle) else { DBG (4, "sane_cancel: scan has not been initiated yet, " - "or it is allready aborted\n"); + "or it is already aborted\n"); } DBG (5, "sane_cancel: exit\n"); return; diff --git a/backend/mustek_usb2.c b/backend/mustek_usb2.c index 25b8464..58d9e9e 100644 --- a/backend/mustek_usb2.c +++ b/backend/mustek_usb2.c @@ -1270,14 +1270,12 @@ AutoLevel (SANE_Byte *lpSource, SCANMODE scanMode, unsigned short ScanLines, unsigned short R, G, B, max_R, max_G, max_B, min_R, min_G, min_B; float fmax_R, fmax_G, fmax_B; unsigned int sum_R = 0, sum_G = 0, sum_B = 0; - float mean_R, mean_G, mean_B; unsigned int hisgram_R[256], hisgram_G[256], hisgram_B[256]; unsigned int iWidth = BytesPerLine / 3; unsigned int iHeight = ScanLines; SANE_Byte *pbmpdata = (SANE_Byte *) lpSource; - unsigned int tmp = 0; unsigned short imin_threshold[3]; unsigned short imax_threshold[3]; @@ -1350,10 +1348,6 @@ AutoLevel (SANE_Byte *lpSource, SCANMODE scanMode, unsigned short ScanLines, DBG (DBG_INFO, "AutoLevel: Find min , max is over!\n"); - mean_R = (float) (sum_R / TotalImgSize); - mean_G = (float) (sum_G / TotalImgSize); - mean_B = (float) (sum_B / TotalImgSize); - imin_threshold[0] = 0; imin_threshold[1] = 0; @@ -1372,7 +1366,6 @@ AutoLevel (SANE_Byte *lpSource, SCANMODE scanMode, unsigned short ScanLines, } } - tmp = 0; for (ii = 255; ii >= 0; ii--) { if (hisgram_R[ii] > 0) @@ -1383,7 +1376,6 @@ AutoLevel (SANE_Byte *lpSource, SCANMODE scanMode, unsigned short ScanLines, } } - tmp = 0; for (ii = 0; ii < 256; ii++) { if (hisgram_G[ii] > 0) @@ -1394,7 +1386,6 @@ AutoLevel (SANE_Byte *lpSource, SCANMODE scanMode, unsigned short ScanLines, } } - tmp = 0; for (ii = 255; ii >= 0; ii--) { if (hisgram_G[ii] > 0) @@ -1405,7 +1396,6 @@ AutoLevel (SANE_Byte *lpSource, SCANMODE scanMode, unsigned short ScanLines, } } - tmp = 0; for (ii = 0; ii < 256; ii++) { if (hisgram_B[ii] > 0) @@ -1416,7 +1406,6 @@ AutoLevel (SANE_Byte *lpSource, SCANMODE scanMode, unsigned short ScanLines, } } - tmp = 0; for (ii = 255; ii >= 0; ii--) { if (hisgram_B[ii] > 0) diff --git a/backend/mustek_usb2_asic.c b/backend/mustek_usb2_asic.c index 3019e5e..d9b1a28 100644 --- a/backend/mustek_usb2_asic.c +++ b/backend/mustek_usb2_asic.c @@ -1607,7 +1607,6 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove) STATUS status = STATUS_GOOD; unsigned int motor_steps; SANE_Byte temp_motor_action; - SANE_Byte temp_status; DBG (DBG_ASIC, "LLFMotorMove:Enter\n"); @@ -1727,7 +1726,6 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove) SCAN_BACK_TRACKING_DISABLE | temp_motor_action); Mustek_SendData (chip, ES01_F4_ActiveTriger, ACTION_TRIGER_ENABLE); - temp_status = 0; if (LLF_MotorMove->WaitOrNoWait == 1) { if (LLF_MotorMove->ActionType == ACTION_TYPE_BACKTOHOME) @@ -3020,10 +3018,8 @@ SetPackAddress (PAsic chip, unsigned short wXResolution, unsigned short wWidth, { STATUS status = STATUS_GOOD; - unsigned short LineTotalOverlapPixel; SANE_Byte OverLapPixel; SANE_Byte TotalLineShift; - SANE_Byte InvalidPixelNumberBackup; unsigned short SegmentTotalPixel; unsigned int dwLineTotalPixel; unsigned short ValidPixelNumber = *PValidPixelNumber; @@ -3038,7 +3034,6 @@ SetPackAddress (PAsic chip, unsigned short wXResolution, unsigned short wWidth, DBG (DBG_ASIC, "SetPackAddress:Enter\n"); - LineTotalOverlapPixel = 0; OverLapPixel = 0; TotalLineShift = 1; PackAreaUseLine = TotalLineShift + 1; @@ -3067,7 +3062,6 @@ SetPackAddress (PAsic chip, unsigned short wXResolution, unsigned short wWidth, Mustek_SendData (chip, ES01_2C0_VALID_PIXEL_PARAMETER_OF_SEGMENT1 + i, 0); } - LineTotalOverlapPixel = OverLapPixel * 16; FinalLinePixelPerSegment = ValidPixelNumber + OverLapPixel * 2; @@ -3080,8 +3074,6 @@ SetPackAddress (PAsic chip, unsigned short wXResolution, unsigned short wWidth, InValidPixelNumber = 0; } - InvalidPixelNumberBackup = InValidPixelNumber; - Mustek_SendData (chip, ES01_1B0_SEGMENT_PIXEL_NUMBER_LB, LOBYTE (ValidPixelNumber)); Mustek_SendData (chip, ES01_1B1_SEGMENT_PIXEL_NUMBER_HB, @@ -3823,9 +3815,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits, unsigned short ValidPixelNumber; - unsigned short wPerLineNeedBufferSize = 0; unsigned short BytePerPixel = 0; - unsigned int dwTotal_PerLineNeedBufferSize = 0; unsigned int dwTotalLineTheBufferNeed = 0; unsigned short dwTotal_CCDResolution = 1200; unsigned short wThinkCCDResolution = 0; @@ -3890,31 +3880,26 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits, /* calculate byte per line */ if (bScanBits > 24) { - wPerLineNeedBufferSize = wWidth * 6; BytePerPixel = 6; chip->dwBytesCountPerRow = (unsigned int) (wWidth) * 6; } else if (bScanBits == 24) { - wPerLineNeedBufferSize = wWidth * 3; BytePerPixel = 3; chip->dwBytesCountPerRow = (unsigned int) (wWidth) * 3; } else if ((bScanBits > 8) && (bScanBits <= 16)) { - wPerLineNeedBufferSize = wWidth * 2; BytePerPixel = 2; chip->dwBytesCountPerRow = (unsigned int) (wWidth) * 2; } else if ((bScanBits == 8)) { - wPerLineNeedBufferSize = wWidth; BytePerPixel = 1; chip->dwBytesCountPerRow = (unsigned int) (wWidth); } else if ((bScanBits < 8)) { - wPerLineNeedBufferSize = wWidth >> 3; BytePerPixel = 1; chip->dwBytesCountPerRow = (unsigned int) (wWidth); } @@ -3983,7 +3968,6 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits, } } - dwTotal_PerLineNeedBufferSize = wPerLineNeedBufferSize; dwTotalLineTheBufferNeed = wLength; chip->Scan.Dpi = wXResolution; @@ -4318,7 +4302,7 @@ Asic_SetSource (PAsic chip, LIGHTSOURCE lsLightSource) DBG (DBG_ASIC, "Asic_SetSource: Source is Reflect\n"); break; case 2: - DBG (DBG_ASIC, "Asic_SetSource: Source is Postion\n"); + DBG (DBG_ASIC, "Asic_SetSource: Source is Position\n"); break; case 4: DBG (DBG_ASIC, "Asic_SetSource: Source is Negtive\n"); @@ -4848,7 +4832,6 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution, unsigned short wPerLineNeedBufferSize = 0; unsigned short BytePerPixel = 0; - unsigned int dwTotal_PerLineNeedBufferSize = 0; unsigned int dwTotalLineTheBufferNeed = 0; unsigned short dwTotal_CCDResolution = 0; unsigned short wThinkCCDResolution = 0; @@ -4952,7 +4935,6 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution, wPerLineNeedBufferSize, BytePerPixel, chip->dwBytesCountPerRow); - dwTotal_PerLineNeedBufferSize = wPerLineNeedBufferSize; dwTotalLineTheBufferNeed = wLength; DBG (DBG_ASIC, "wPerLineNeedBufferSize=%d,wLength=%d\n", wPerLineNeedBufferSize, wLength); diff --git a/backend/mustek_usb2_high.c b/backend/mustek_usb2_high.c index a10dbc7..664528e 100644 --- a/backend/mustek_usb2_high.c +++ b/backend/mustek_usb2_high.c @@ -1696,7 +1696,6 @@ static SANE_Bool MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { - SANE_Byte *lpTemp; unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short wRLinePosOdd = 0; @@ -1717,7 +1716,6 @@ MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, g_isScanning = TRUE; TotalXferLines = 0; wWantedTotalLines = *wLinesCount; - lpTemp = lpLine; if (g_bFirstReadImage) { diff --git a/backend/nec.c b/backend/nec.c index c7af955..d5179d3 100644 --- a/backend/nec.c +++ b/backend/nec.c @@ -2823,7 +2823,7 @@ send_threshold_data(NEC_Scanner *s) SANE_Status sane_start (SANE_Handle handle) { - char *mode, *halftone, *paper, *gamma, *edge, *lightcolor, *adf_fsu; + char *mode, *halftone, *gamma, *edge, *lightcolor, *adf_fsu; NEC_Scanner *s = handle; SANE_Status status; size_t buf_size; @@ -2953,7 +2953,6 @@ sane_start (SANE_Handle handle) mode = s->val[OPT_MODE].s; halftone = s->val[OPT_HALFTONE].s; - paper = s->val[OPT_PAPER].s; gamma = s->val[OPT_GAMMA].s; edge = s->val[OPT_EDGE_EMPHASIS].s; lightcolor = s->val[OPT_LIGHTCOLOR].s; diff --git a/backend/net.c b/backend/net.c index 4beb45d..57889a2 100644 --- a/backend/net.c +++ b/backend/net.c @@ -846,15 +846,15 @@ net_avahi_callback (AvahiClient *c, AvahiClientState state, void * userdata) if (error == AVAHI_ERR_DISCONNECTED) { /* Server disappeared - try to reconnect */ - avahi_client_free (avahi_client); - avahi_client = NULL; - if (avahi_browser) { avahi_service_browser_free (avahi_browser); avahi_browser = NULL; } + avahi_client_free (avahi_client); + avahi_client = NULL; + avahi_client = avahi_client_new (avahi_threaded_poll_get (avahi_thread), AVAHI_CLIENT_NO_FAIL, net_avahi_callback, NULL, &error); if (avahi_client == NULL) { diff --git a/backend/niash.c b/backend/niash.c index 950df21..bbc90d3 100644 --- a/backend/niash.c +++ b/backend/niash.c @@ -1491,7 +1491,7 @@ sane_set_io_mode (SANE_Handle __sane_unused__ h, SANE_Bool m) SANE_Status -sane_get_select_fd (SANE_Handle __sane_unused__ h, SANE_Int * __sane_unused__ fd) +sane_get_select_fd (SANE_Handle __sane_unused__ h, SANE_Int __sane_unused__ * fd) { DBG (DBG_MSG, "sane_select_fd\n"); return SANE_STATUS_UNSUPPORTED; diff --git a/backend/niash_core.c b/backend/niash_core.c index e3ae2b8..b87f4f6 100644 --- a/backend/niash_core.c +++ b/backend/niash_core.c @@ -645,9 +645,6 @@ InitScan (TScanParams * pParams, THWParams * pHWParams) int iHeight; int iExpTime; TScanParams Params; - int iHandle; - - iHandle = pHWParams->iXferHandle; /* check validity of scanparameters */ switch (pParams->iDpi) @@ -1228,7 +1225,7 @@ SimpleCalibExt (THWParams * pHWPar, unsigned char *pabCalibTable, SANE_Bool iReversedHead; int startWhiteY, endWhiteY; int startBlackY, endBlackY; - int startBlackX, endBlackX; + int endBlackX; iHandle = pHWPar->iXferHandle; iReversedHead = pHWPar->iReversedHead; @@ -1265,7 +1262,6 @@ SimpleCalibExt (THWParams * pHWPar, unsigned char *pabCalibTable, endWhiteY = 15; startBlackY = 16; endBlackY = 135; - startBlackX = 0; endBlackX = HW_PIXELS; } else @@ -1274,7 +1270,6 @@ SimpleCalibExt (THWParams * pHWPar, unsigned char *pabCalibTable, endWhiteY = 70; startBlackY = 86; endBlackY = 135; - startBlackX = 1666; endBlackX = 3374; } diff --git a/backend/p5_device.c b/backend/p5_device.c index c065ca2..924144e 100644 --- a/backend/p5_device.c +++ b/backend/p5_device.c @@ -214,19 +214,19 @@ read_data (int fd, uint8_t * data, int length) static void index_write_data (int fd, uint8_t index, uint8_t * data, int length) { - int mode, rc; + int mode; unsigned char bval; bval = index; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; - rc = ioctl (fd, PPSETMODE, &mode); - rc = write (fd, &bval, 1); + ioctl (fd, PPSETMODE, &mode); + write (fd, &bval, 1); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; - rc = ioctl (fd, PPSETMODE, &mode); + ioctl (fd, PPSETMODE, &mode); mode = 0; /* data forward */ - rc = ioctl (fd, PPDATADIR, &mode); - rc = write (fd, data, length); + ioctl (fd, PPDATADIR, &mode); + write (fd, data, length); return; } @@ -469,7 +469,7 @@ setadresses (int fd, uint16_t start, uint16_t end) static int open_pp (const char *devicename) { - int fd, rc, mode = 0; + int fd, mode = 0; char *name; DBG (DBG_proc, "open_pp: start, devicename=%s\n", devicename); @@ -512,8 +512,8 @@ open_pp (const char *devicename) free(name); /* claim device and set it to EPP */ - rc = ioctl (fd, PPCLAIM); - rc = ioctl (fd, PPGETMODES, &mode); + ioctl (fd, PPCLAIM); + ioctl (fd, PPGETMODES, &mode); if (mode & PARPORT_MODE_PCSPP) DBG (DBG_io, "PARPORT_MODE_PCSPP\n"); if (mode & PARPORT_MODE_TRISTATE) @@ -546,12 +546,12 @@ open_pp (const char *devicename) if (mode == -1) { DBG (DBG_error, "open_pp: no EPP mode, giving up ...\n"); - rc = ioctl (fd, PPRELEASE); + ioctl (fd, PPRELEASE); close (fd); return -1; } - rc = ioctl (fd, PPNEGOT, &mode); - rc = ioctl (fd, PPSETMODE, &mode); + ioctl (fd, PPNEGOT, &mode); + ioctl (fd, PPSETMODE, &mode); DBG (DBG_proc, "open_pp: exit\n"); return fd; } diff --git a/backend/pie.c b/backend/pie.c index 941ed62..76cbb47 100644 --- a/backend/pie.c +++ b/backend/pie.c @@ -2781,7 +2781,7 @@ pie_reader_process (Pie_Scanner * scanner, FILE * fp) /* --------------------------------- READER PROCESS SIGTERM HANDLER ------------ */ -static RETSIGTYPE +static void reader_process_sigterm_handler (int signal) { DBG (DBG_sane_info, "reader_process: terminated by signal %d\n", signal); @@ -2896,7 +2896,7 @@ do_cancel (Pie_Scanner * scanner) scanner->scanning = SANE_FALSE; - if (scanner->reader_pid != -1) + if (sanei_thread_is_valid (scanner->reader_pid)) { DBG (DBG_sane_info, "killing reader_process\n"); sanei_thread_kill (scanner->reader_pid); @@ -3703,7 +3703,7 @@ sane_start (SANE_Handle handle) scanner->reader_fds = fds[1]; scanner->reader_pid = sanei_thread_begin( reader_process, (void*)scanner ); - if (scanner->reader_pid == -1) + if (!sanei_thread_is_valid (scanner->reader_pid)) { DBG (1, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)); diff --git a/backend/pieusb.c b/backend/pieusb.c index 4b07304..9730888 100644 --- a/backend/pieusb.c +++ b/backend/pieusb.c @@ -109,6 +109,10 @@ extern void write_tiff_rgbi_header (FILE *fptr, int width, int height, int depth #define DBG_info_scan 11 /* information scanner commands */ #define DBG_info_usb 13 /* information usb level functions */ +/* device flags */ + +#define FLAG_SLIDE_TRANSPORT 0x01 + /* -------------------------------------------------------------------------- * * SUPPORTED DEVICES SPECIFICS @@ -150,7 +154,8 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize char config_line[PATH_MAX]; SANE_Word vendor_id; SANE_Word product_id; - SANE_Word model_number; + SANE_Int model_number; + SANE_Int flags; SANE_Status status; int i; @@ -183,18 +188,22 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize pieusb_supported_usb_device_list[0].vendor = 0x05e3; pieusb_supported_usb_device_list[0].product = 0x0145; pieusb_supported_usb_device_list[0].model = 0x30; + pieusb_supported_usb_device_list[0].flags = 0; /* Reflecta ProScan 7200, model number 0x36 */ pieusb_supported_usb_device_list[1].vendor = 0x05e3; pieusb_supported_usb_device_list[1].product = 0x0145; pieusb_supported_usb_device_list[1].model = 0x36; - /* Reflecta 6000 Multiple Slide Scanner */ + pieusb_supported_usb_device_list[1].flags = 0; + /* Reflecta 6000 Multiple Slide Scanner, model number 0x3a */ pieusb_supported_usb_device_list[2].vendor = 0x05e3; pieusb_supported_usb_device_list[2].product = 0x0142; pieusb_supported_usb_device_list[2].model = 0x3a; + pieusb_supported_usb_device_list[2].flags = FLAG_SLIDE_TRANSPORT; /* end of list */ pieusb_supported_usb_device_list[3].vendor = 0; pieusb_supported_usb_device_list[3].product = 0; pieusb_supported_usb_device_list[3].model = 0; + pieusb_supported_usb_device_list[3].flags = 0; /* Add entries from config file */ fp = sanei_config_open (PIEUSB_CONFIG_FILE); @@ -209,14 +218,14 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize if (strncmp (config_line, "usb ", 4) != 0) continue; /* Parse vendor-id, product-id and model number and add to list */ DBG (DBG_info_sane, "sane_init() config file parsing %s\n", config_line); - status = sanei_pieusb_parse_config_line(config_line, &vendor_id, &product_id, &model_number); + status = sanei_pieusb_parse_config_line(config_line, &vendor_id, &product_id, &model_number, &flags); if (status == SANE_STATUS_GOOD) { - DBG (DBG_info_sane, "sane_init() config file lists device %04x %04x %02x\n",vendor_id, product_id, model_number); - if (!sanei_pieusb_supported_device_list_contains(vendor_id, product_id, model_number)) { - DBG (DBG_info_sane, "sane_init() adding device %04x %04x %02x\n",vendor_id, product_id, model_number); - sanei_pieusb_supported_device_list_add(vendor_id, product_id, model_number); + DBG (DBG_info_sane, "sane_init() config file lists device %04x %04x %02x %02x\n",vendor_id, product_id, model_number, flags); + if (!sanei_pieusb_supported_device_list_contains(vendor_id, product_id, model_number, flags)) { + DBG (DBG_info_sane, "sane_init() adding device %04x %04x %02x %02x\n",vendor_id, product_id, model_number, flags); + sanei_pieusb_supported_device_list_add(vendor_id, product_id, model_number, flags); } else { - DBG (DBG_info_sane, "sane_init() list already contains %04x %04x %02x\n", vendor_id, product_id, model_number); + DBG (DBG_info_sane, "sane_init() list already contains %04x %04x %02x %02x\n", vendor_id, product_id, model_number, flags); } } else { DBG (DBG_info_sane, "sane_init() config file parsing %s: error\n", config_line); @@ -235,8 +244,13 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize pieusb_supported_usb_device.vendor = pieusb_supported_usb_device_list[i].vendor; pieusb_supported_usb_device.product = pieusb_supported_usb_device_list[i].product; pieusb_supported_usb_device.model = pieusb_supported_usb_device_list[i].model; + pieusb_supported_usb_device.flags = pieusb_supported_usb_device_list[i].flags; pieusb_supported_usb_device.device_number = -1; /* No device number (yet) */ - DBG( DBG_info_sane, "sane_init() looking for Reflecta scanner %04x %04x model %02x\n", pieusb_supported_usb_device.vendor, pieusb_supported_usb_device.product, pieusb_supported_usb_device.model); + DBG( DBG_info_sane, "sane_init() looking for scanner %04x %04x model %02x, flags %02x\n", + pieusb_supported_usb_device.vendor, + pieusb_supported_usb_device.product, + pieusb_supported_usb_device.model, + pieusb_supported_usb_device.flags); sanei_usb_find_devices (pieusb_supported_usb_device.vendor, pieusb_supported_usb_device.product, sanei_pieusb_find_device_callback); i++; } @@ -354,6 +368,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) pieusb_supported_usb_device.vendor = vendor; pieusb_supported_usb_device.product = product; pieusb_supported_usb_device.model = pieusb_supported_usb_device_list[i].model; + pieusb_supported_usb_device.flags = pieusb_supported_usb_device_list[i].flags; pieusb_supported_usb_device.device_number = -1; sanei_usb_find_devices (vendor, product, sanei_pieusb_find_device_callback); if (pieusb_supported_usb_device.device_number == -1) { @@ -994,17 +1009,18 @@ sane_start (SANE_Handle handle) * * ---------------------------------------------------------------------- */ - sanei_pieusb_cmd_17 (scanner->device_number, 1, &status); - if (status.pieusb_status != PIEUSB_STATUS_GOOD) { - DBG (DBG_error, "sane_start(): sanei_pieusb_cmd_17 failed: %d\n", status.pieusb_status); - return SANE_STATUS_IO_ERROR; - } - st = sanei_pieusb_wait_ready (scanner, 0); - if (st != SANE_STATUS_GOOD) { - DBG (DBG_error, "sane_start(): scanner not ready after sanei_pieusb_cmd_17: %d\n", st); - return st; + if (scanner->device->flags & FLAG_SLIDE_TRANSPORT) { + sanei_pieusb_cmd_17 (scanner->device_number, 1, &status); + if (status.pieusb_status != PIEUSB_STATUS_GOOD) { + DBG (DBG_error, "sane_start(): sanei_pieusb_cmd_17 failed: %d\n", status.pieusb_status); + return SANE_STATUS_IO_ERROR; + } + st = sanei_pieusb_wait_ready (scanner, 0); + if (st != SANE_STATUS_GOOD) { + DBG (DBG_error, "sane_start(): scanner not ready after sanei_pieusb_cmd_17: %d\n", st); + return st; + } } - /* ---------------------------------------------------------------------- * * Get & set initial gains and offsets @@ -1039,20 +1055,21 @@ sane_start (SANE_Handle handle) /* ---------------------------------------------------------------------- * - * Lamp on + * Init slide transport * * ---------------------------------------------------------------------- */ - sanei_pieusb_cmd_slide (scanner->device_number, SLIDE_LAMP_ON, &status); - if (status.pieusb_status != PIEUSB_STATUS_GOOD) { - DBG (DBG_error, "sane_start(): sanei_pieusb_cmd_slide failed: %d\n", status.pieusb_status); - return SANE_STATUS_IO_ERROR; - } - st = sanei_pieusb_wait_ready (scanner, 0); - if (st != SANE_STATUS_GOOD) { - DBG (DBG_error, "sane_start: scanner not ready %d\n", st); - return st; + if (scanner->device->flags & FLAG_SLIDE_TRANSPORT) { + sanei_pieusb_cmd_slide (scanner->device_number, SLIDE_INIT, &status); + if (status.pieusb_status != PIEUSB_STATUS_GOOD) { + DBG (DBG_error, "sane_start(): sanei_pieusb_cmd_slide failed: %d\n", status.pieusb_status); + return SANE_STATUS_IO_ERROR; + } + st = sanei_pieusb_wait_ready (scanner, 0); + if (st != SANE_STATUS_GOOD) { + DBG (DBG_error, "sane_start: scanner not ready %d\n", st); + return st; + } } - /* Enter SCAN phase 1 */ DBG (DBG_info_sane, "sane_start(): scan phase 1\n"); @@ -1200,12 +1217,14 @@ sane_start (SANE_Handle handle) * Advance to next slide (except for preview) * * ---------------------------------------------------------------------- */ - if (scanner->val[OPT_ADVANCE_SLIDE].b && !scanner->val[OPT_PREVIEW].b) { - sanei_pieusb_cmd_slide (scanner->device_number, SLIDE_NEXT, &status); - if (status.pieusb_status != PIEUSB_STATUS_GOOD) { - DBG (DBG_error, "sane_start(): sanei_pieusb_cmd_slide failed: %d\n", status.pieusb_status); - } + if (scanner->device->flags & FLAG_SLIDE_TRANSPORT) { + if (scanner->val[OPT_ADVANCE_SLIDE].b && !scanner->val[OPT_PREVIEW].b) { + sanei_pieusb_cmd_slide (scanner->device_number, SLIDE_NEXT, &status); + if (status.pieusb_status != PIEUSB_STATUS_GOOD) { + DBG (DBG_error, "sane_start(): sanei_pieusb_cmd_slide failed: %d\n", status.pieusb_status); + } + } } /* ---------------------------------------------------------------------- diff --git a/backend/pieusb.conf.in b/backend/pieusb.conf.in index ec5ba7e..8904d3d 100644 --- a/backend/pieusb.conf.in +++ b/backend/pieusb.conf.in @@ -1,9 +1,20 @@ # pieusb.conf: Configuration file for PIE/Reflecta USB scanner # Read man sane-pieusb for documentation -# Autodetect -# Reflecta 6000 Multiple Slide Scanner -usb 0x05e3 0x0142 +# Format +# usb +# +# Autodetect (built-in) +# Reflecta DigitDia 6000 Multiple Slide Scanner +# usb 0x05e3 0x0142 0x3a 0x01 # Reflecta CrystalScan 7200 +# usb 0x05e3 0x0145 0x30 0x00 # Reflecta ProScan 7200 -usb 0x05e3 0x0145 +# usb 0x05e3 0x0145 0x36 0x00 + +# Reflecta ProScan 10T +usb 0x05e3 0x0145 0x47 0x00 +# Reflecta CrystalScan 3600 +usb 0x05e3 0x0145 0x2e 0x00 +# Reflecta DigitDia 4000 +usb 0x05e3 0x0142 0x2f 0x00 diff --git a/backend/pieusb.h b/backend/pieusb.h index 10ce106..dc4cda7 100644 --- a/backend/pieusb.h +++ b/backend/pieusb.h @@ -80,6 +80,7 @@ struct Pieusb_USB_Device_Entry SANE_Word product; /* USB product identifier */ SANE_Word model; /* USB model number */ SANE_Int device_number; /* USB device number if the device is present */ + SANE_Int flags; /* flags */ }; extern struct Pieusb_USB_Device_Entry* pieusb_supported_usb_device_list; diff --git a/backend/pieusb_buffer.c b/backend/pieusb_buffer.c index 53bd867..8c67a65 100644 --- a/backend/pieusb_buffer.c +++ b/backend/pieusb_buffer.c @@ -100,15 +100,8 @@ #include #include #include -#include -/* When creating the release backend, make complains about unresolved external - * le16toh, although it finds the include */ -#if __BYTE_ORDER == __LITTLE_ENDIAN - #define le16toh(x) (x) -#else - #define le16toh(x) __bswap_16 (x) -#endif +#include "byteorder.h" static void buffer_update_read_index(struct Pieusb_Read_Buffer* buffer, int increment); @@ -163,7 +156,7 @@ sanei_pieusb_buffer_create(struct Pieusb_Read_Buffer* buffer, SANE_Int width, SA snprintf(buffer->buffer_name, L_tmpnam, "/tmp/sane.XXXXXX"); if (buffer->data_file != 0) /* might still be open from previous invocation */ close(buffer->data_file); - buffer->data_file = mkostemp(buffer->buffer_name, O_RDWR | O_CREAT | O_EXCL | O_TRUNC); + buffer->data_file = mkstemp(buffer->buffer_name); if (buffer->data_file == -1) { buffer->data_file = 0; buffer->data = NULL; diff --git a/backend/pieusb_scancmd.c b/backend/pieusb_scancmd.c index a86f8fe..672716f 100644 --- a/backend/pieusb_scancmd.c +++ b/backend/pieusb_scancmd.c @@ -212,7 +212,7 @@ sanei_pieusb_cmd_test_unit_ready(SANE_Int device_number, struct Pieusb_Command_S /** * slide action - * @param action SLIDE_NEXT, SLIDE_PREV, SLIDE_LAMP_ON, SLIDE_RELOAD + * @param action SLIDE_NEXT, SLIDE_PREV, SLIDE_INIT, SLIDE_RELOAD * @return Pieusb_Command_Status */ @@ -294,57 +294,6 @@ sanei_pieusb_cmd_get_sense(SANE_Int device_number, struct Pieusb_Sense* sense, s free(sd); } -/** - * Read the halftone pattern with the specified index. This requires two - * commands, one to ask the device to prepare the pattern, and one to read it. - * - * @param device_number Device number - * @param index index of halftone pattern - * @param pattern Halftone pattern (not implemented) - * @return Pieusb_Command_Status - * @see Pieusb_Halftone_Pattern - */ -void -sanei_pieusb_cmd_get_halftone_pattern(SANE_Int device_number, SANE_Int index, struct Pieusb_Halftone_Pattern* pattern, struct Pieusb_Command_Status *status) -{ - SANE_Byte command[SCSI_COMMAND_LEN]; -#define PATTERN_SIZE 256 /* Assumed maximum pattern size */ - SANE_Int size = PATTERN_SIZE; - SANE_Byte data[PATTERN_SIZE]; - int psize; - SANE_Char* desc; - PIEUSB_Status st; - - DBG (DBG_info_scan, "sanei_pieusb_cmd_get_halftone_pattern()\n"); - - /* Ask scanner to prepare the pattern with the given index. Only SCSI_COMMAND_LEN bytes of data. */ - _prep_scsi_cmd(command, SCSI_WRITE, SCSI_COMMAND_LEN); - memset(data, '\0', SCSI_COMMAND_LEN); - data[0] = SCSI_HALFTONE_PATTERN | 0x80; /* set bit 7 means prepare read */ - data[4] = index; - - st = sanei_pieusb_command(device_number, command, data, SCSI_COMMAND_LEN); - if (st != PIEUSB_STATUS_GOOD) { - status->pieusb_status = st; - /* FIXME */ - return; - } - - /* Read pattern */ - _prep_scsi_cmd(command, SCSI_READ, size); - - memset(data, '\0', size); - status->pieusb_status = sanei_pieusb_command (device_number, command, data, size); - - /*FIXME: analyse */ - fprintf(stderr, "Halftone pattern %d:\n", index); - psize = (data[3]<<8) + data[2]; - desc = (SANE_Char*)(data + 4 + psize); - data[4 + psize + 16] = '\0'; - fprintf(stderr,"Descr. offset from byte 4 = %d, %16s, index = %d, size = %dx%d\n", psize, desc, data[4]&0x7F, data[6], data[7]); -#undef PATTERN_SIZE -} - /** * Read the scan frame with the specified index. This requires two * commands, one to ask the device to prepare the pattern, and one to read it. @@ -425,38 +374,6 @@ sanei_pieusb_cmd_17(SANE_Int device_number, SANE_Int value, struct Pieusb_Comman } } -/** - * Read the relative exposure time for the specified colorbits. This requires two - * commands, one to ask the device to prepare the value, and one to read it. - * - * @param device_number Device number - * @param time Relative exposure time(s) - * @return Pieusb_Command_Status - * @see Pieusb_Exposure_Time - */ -void -sanei_pieusb_cmd_get_exposure_time(SANE_Int device_number, SANE_Int colorbits, struct Pieusb_Exposure_Time* time, struct Pieusb_Command_Status *status) -{ - DBG (DBG_info_scan, "sanei_pieusb_cmd_get_exposure_time(): not implemented\n"); - status->pieusb_status = PIEUSB_STATUS_INVAL; -} - -/** - * Read the highlight and shadow levels with the specified colorbits. This requires two - * commands, one to ask the device to prepare the value, and one to read it. - * - * @param device_number Device number - * @param hgltshdw Highlight and shadow level(s) - * @return Pieusb_Command_Status - * @see Pieusb_Highlight_Shadow - */ -void -sanei_pieusb_cmd_get_highlight_shadow(SANE_Int device_number, SANE_Int colorbits, struct Pieusb_Highlight_Shadow* hgltshdw, struct Pieusb_Command_Status *status) -{ - DBG (DBG_info_scan, "sanei_pieusb_cmd_get_highlight_shadow(): not implemented\n"); - status->pieusb_status = PIEUSB_STATUS_INVAL; -} - /** * Read the shading data parameters. This requires two * commands, one to ask the device to prepare the value, and one to read it. @@ -551,23 +468,6 @@ sanei_pieusb_cmd_get_scanned_lines(SANE_Int device_number, SANE_Byte* data, SANE status->pieusb_status = sanei_pieusb_command (device_number, command, data, size); } -/** - * Set the halftone pattern with the given index to the specified pattern. The - * command is a SCSI WRITE command (code 0x0A, write code 0x11). - * - * @param device_number Device number - * @param index Pattern index (0-7) - * @param pattern Halftone pattern (not implemented) - * @return Pieusb_Command_Status - * @see Pieusb_Halftone_Pattern - */ -void -sanei_pieusb_cmd_set_halftone_pattern(SANE_Int device_number, SANE_Int index, struct Pieusb_Halftone_Pattern* pattern, struct Pieusb_Command_Status *status) -{ - DBG (DBG_info_scan, "sanei_pieusb_cmd_set_halftone_pattern(): not implemented\n"); - status->pieusb_status = PIEUSB_STATUS_INVAL; -} - /** * Set the scan frame with the given index to the frame. The command is a SCSI * WRITE command (code SCSI_WRITE, write code SCSI_SCAN_FRAME). @@ -682,24 +582,6 @@ sanei_pieusb_cmd_set_highlight_shadow(SANE_Int device_number, struct Pieusb_High #undef HIGHLIGHT_SHADOW_SIZE } -/** - * Set the CCD-mask for the colors set in the given color bit mask. The mask - * array must contain mask_size. The command is a SCSI WRITE command - * (code 0x0A, write code 0x16). - * (The command is able to handle more masks at once, but that is not implemented.) - * - * @param device_number Device number - * @param colorbits 0000RGB0 color bit mask; at least one color bit must be set - * @param mask CCD mask to use - * @return Pieusb_Command_Status - */ -void -sanei_pieusb_cmd_set_ccd_mask(SANE_Int device_number, SANE_Byte colorbits, SANE_Byte* mask, SANE_Int mask_size, struct Pieusb_Command_Status *status) -{ - DBG (DBG_info_scan, "sanei_pieusb_cmd_set_ccd_mask(): not implemented\n"); - status->pieusb_status = PIEUSB_STATUS_INVAL; -} - /* SCSI PARAM, code 0x0F */ /** * Get the parameters of an executed scan, such as width, lines and bytes, which diff --git a/backend/pieusb_scancmd.h b/backend/pieusb_scancmd.h index 0dee646..5eefa55 100644 --- a/backend/pieusb_scancmd.h +++ b/backend/pieusb_scancmd.h @@ -318,7 +318,7 @@ struct Pieusb_Command_Status { typedef struct Pieusb_Scanner_Properties Pieusb_Scanner_Properties; typedef enum { - SLIDE_NEXT = 0x04, SLIDE_PREV = 0x05, SLIDE_LAMP_ON = 0x10, SLIDE_RELOAD = 0x40 + SLIDE_NEXT = 0x04, SLIDE_PREV = 0x05, SLIDE_INIT = 0x10, SLIDE_RELOAD = 0x40 } slide_action; void sanei_pieusb_cmd_slide(SANE_Int device_number, slide_action action, struct Pieusb_Command_Status *status); diff --git a/backend/pieusb_specific.c b/backend/pieusb_specific.c index 8231075..ce107cf 100644 --- a/backend/pieusb_specific.c +++ b/backend/pieusb_specific.c @@ -292,6 +292,8 @@ sanei_pieusb_find_device_callback (const char *devicename) return SANE_STATUS_INVAL; } + dev->flags = pieusb_supported_usb_device.flags; + /* Found a supported scanner, put it in the definitions list*/ DBG (DBG_info_proc, "sanei_pieusb_find_device_callback: success\n"); dev->next = pieusb_definition_list_head; @@ -996,18 +998,23 @@ sanei_pieusb_init_options (Pieusb_Scanner* scanner) } /** - * Parse line from config file into a vendor id, product id and a model number + * Parse line from config file into a vendor id, product id, model number, and flags * * @param config_line Text to parse * @param vendor_id * @param product_id * @param model_number + * @param flags * @return SANE_STATUS_GOOD, or SANE_STATUS_INVAL in case of a parse error */ SANE_Status -sanei_pieusb_parse_config_line(const char* config_line, SANE_Word* vendor_id, SANE_Word* product_id, SANE_Word* model_number) +sanei_pieusb_parse_config_line(const char* config_line, + SANE_Word* vendor_id, + SANE_Word* product_id, + SANE_Int* model_number, + SANE_Int* flags) { - char *vendor_id_string, *product_id_string, *model_number_string; + char *vendor_id_string, *product_id_string, *model_number_string, *flags_string; if (strncmp (config_line, "usb ", 4) != 0) { return SANE_STATUS_INVAL; @@ -1041,12 +1048,12 @@ sanei_pieusb_parse_config_line(const char* config_line, SANE_Word* vendor_id, SA } else { return SANE_STATUS_INVAL; } - /* Detect product-id */ + /* Detect model number */ config_line = sanei_config_skip_whitespace (config_line); if (*config_line) { config_line = sanei_config_get_string (config_line, &model_number_string); if (model_number_string) { - *model_number = strtol (model_number_string, 0, 0); + *model_number = (SANE_Int) strtol (model_number_string, 0, 0); free (model_number_string); } else { return SANE_STATUS_INVAL; @@ -1055,6 +1062,16 @@ sanei_pieusb_parse_config_line(const char* config_line, SANE_Word* vendor_id, SA } else { return SANE_STATUS_INVAL; } + /* Detect (optional) flags */ + *flags = 0; + config_line = sanei_config_skip_whitespace (config_line); + if (*config_line) { + config_line = sanei_config_get_string (config_line, &flags_string); + if (flags_string) { + *flags = (SANE_Int) strtol (flags_string, 0, 0); + free (flags_string); + } + } return SANE_STATUS_GOOD; } @@ -1064,16 +1081,18 @@ sanei_pieusb_parse_config_line(const char* config_line, SANE_Word* vendor_id, SA * @param vendor_id * @param product_id * @param model_number + * @param flags * @return */ SANE_Bool -sanei_pieusb_supported_device_list_contains(SANE_Word vendor_id, SANE_Word product_id, SANE_Word model_number) +sanei_pieusb_supported_device_list_contains(SANE_Word vendor_id, SANE_Word product_id, SANE_Int model_number, SANE_Int flags) { int i = 0; while (pieusb_supported_usb_device_list[i].vendor != 0) { if (pieusb_supported_usb_device_list[i].vendor == vendor_id && pieusb_supported_usb_device_list[i].product == product_id - && pieusb_supported_usb_device_list[i].model == model_number) { + && pieusb_supported_usb_device_list[i].model == model_number + && pieusb_supported_usb_device_list[i].flags == flags) { return SANE_TRUE; } i++; @@ -1086,10 +1105,11 @@ sanei_pieusb_supported_device_list_contains(SANE_Word vendor_id, SANE_Word produ * @param vendor_id * @param product_id * @param model_number + * @param flags * @return */ SANE_Status -sanei_pieusb_supported_device_list_add(SANE_Word vendor_id, SANE_Word product_id, SANE_Word model_number) +sanei_pieusb_supported_device_list_add(SANE_Word vendor_id, SANE_Word product_id, SANE_Int model_number, SANE_Int flags) { int i = 0, k; struct Pieusb_USB_Device_Entry* dl; @@ -1099,10 +1119,11 @@ sanei_pieusb_supported_device_list_add(SANE_Word vendor_id, SANE_Word product_id } /* i is index of last entry */ for (k=0; k<=i; k++) { - DBG(DBG_info_proc,"sanei_pieusb_supported_device_list_add(): current %03d: %04x %04x %02x\n", i, + DBG(DBG_info_proc,"sanei_pieusb_supported_device_list_add(): current %03d: %04x %04x %02x %02x\n", i, pieusb_supported_usb_device_list[k].vendor, pieusb_supported_usb_device_list[k].product, - pieusb_supported_usb_device_list[k].model); + pieusb_supported_usb_device_list[k].model, + pieusb_supported_usb_device_list[k].flags); } dl = realloc(pieusb_supported_usb_device_list,(i+2)*sizeof(struct Pieusb_USB_Device_Entry)); /* Add one entry to list */ @@ -1114,14 +1135,17 @@ sanei_pieusb_supported_device_list_add(SANE_Word vendor_id, SANE_Word product_id pieusb_supported_usb_device_list[i].vendor = vendor_id; pieusb_supported_usb_device_list[i].product = product_id; pieusb_supported_usb_device_list[i].model = model_number; + pieusb_supported_usb_device_list[i].flags = flags; pieusb_supported_usb_device_list[i+1].vendor = 0; pieusb_supported_usb_device_list[i+1].product = 0; pieusb_supported_usb_device_list[i+1].model = 0; + pieusb_supported_usb_device_list[i+1].flags = 0; for (k=0; k<=i+1; k++) { - DBG(DBG_info_proc,"sanei_pieusb_supported_device_list_add() add: %03d: %04x %04x %02x\n", i, + DBG(DBG_info_proc,"sanei_pieusb_supported_device_list_add() add: %03d: %04x %04x %02x %02x\n", i, pieusb_supported_usb_device_list[k].vendor, pieusb_supported_usb_device_list[k].product, - pieusb_supported_usb_device_list[k].model); + pieusb_supported_usb_device_list[k].model, + pieusb_supported_usb_device_list[k].flags); } return SANE_STATUS_GOOD; } diff --git a/backend/pieusb_specific.h b/backend/pieusb_specific.h index 3928adf..f516960 100644 --- a/backend/pieusb_specific.h +++ b/backend/pieusb_specific.h @@ -193,6 +193,7 @@ struct Pieusb_Device_Definition /* USB id's like 0x05e3 0x0145, see pieusb.conf */ SANE_String version; /* INQUIRY productRevision */ SANE_Byte model; /* INQUIRY model */ + SANE_Byte flags; /* pieusb.conf flags */ /* Ranges for various quantities */ SANE_Range dpi_range; @@ -315,7 +316,11 @@ struct Pieusb_Scanner typedef struct Pieusb_Scanner Pieusb_Scanner; -SANE_Status sanei_pieusb_parse_config_line(const char* config_line, SANE_Word* vendor_id, SANE_Word* product_id, SANE_Word* model_number); +SANE_Status sanei_pieusb_parse_config_line(const char* config_line, + SANE_Word* vendor_id, + SANE_Word* product_id, + SANE_Int* model_number, + SANE_Int* flags); /* sub to sane_start() */ SANE_Status sanei_pieusb_post (Pieusb_Scanner *scanner, uint16_t **in_img, int planes); void sanei_pieusb_correct_shading(struct Pieusb_Scanner *scanner, struct Pieusb_Read_Buffer *buffer); @@ -329,8 +334,8 @@ SANE_Status sanei_pieusb_set_frame_from_options(Pieusb_Scanner * scanner); void sanei_pieusb_print_options(struct Pieusb_Scanner *scanner); /* sub to sane_control_option() and sane_start() */ int sanei_pieusb_analyse_options(struct Pieusb_Scanner *scanner); -SANE_Bool sanei_pieusb_supported_device_list_contains(SANE_Word vendor_id, SANE_Word product_id, SANE_Word model_number); -SANE_Status sanei_pieusb_supported_device_list_add(SANE_Word vendor_id, SANE_Word product_id, SANE_Word model_number); +SANE_Bool sanei_pieusb_supported_device_list_contains(SANE_Word vendor_id, SANE_Word product_id, SANE_Int model_number, SANE_Int flags); +SANE_Status sanei_pieusb_supported_device_list_add(SANE_Word vendor_id, SANE_Word product_id, SANE_Int model_number, SANE_Int flags); /* sub to sane_init() and sane_open() */ SANE_Status sanei_pieusb_find_device_callback (const char *devicename); /* sub to sane_open() */ diff --git a/backend/pixma.c b/backend/pixma.c index 3396155..d50e4ca 100644 --- a/backend/pixma.c +++ b/backend/pixma.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -782,6 +782,14 @@ control_option (pixma_sane_t * ss, SANE_Int n, enable_option (ss, opt_threshold, SANE_FALSE); enable_option (ss, opt_threshold_curve, SANE_FALSE); } + if (cfg->cap & (PIXMA_CAP_ADF_WAIT)) + { /* adf-wait */ + enable_option (ss, opt_adf_wait, SANE_TRUE); + } + else + { /* disable adf-wait */ + enable_option (ss, opt_adf_wait, SANE_FALSE); + } *info |= SANE_INFO_RELOAD_OPTIONS; } break; @@ -801,6 +809,7 @@ print_scan_param (int level, const pixma_scan_param_t * sp) sp->xdpi, sp->ydpi, sp->x, sp->y, sp->w, sp->h); pixma_dbg (level, " gamma_table=%p source=%d\n", sp->gamma_table, sp->source); + pixma_dbg (level, " adf-wait=%d\n", sp->adf_wait); } #endif @@ -850,6 +859,7 @@ calc_scan_param (pixma_sane_t * ss, pixma_scan_param_t * sp) sp->adf_pageid = ss->page_count; sp->threshold = 2.55 * OVAL (opt_threshold).w; sp->threshold_curve = OVAL (opt_threshold_curve).w; + sp->adf_wait = OVAL (opt_adf_wait).w; error = pixma_check_scan_param (ss->s, sp); if (error < 0) @@ -928,7 +938,7 @@ init_option_descriptors (pixma_sane_t * ss) /* Writing to reader_ss outside reader_process() is a BUG! */ static pixma_sane_t *reader_ss = NULL; -static RETSIGTYPE +static void reader_signal_handler (int sig) { if (reader_ss) @@ -1083,7 +1093,7 @@ terminate_reader_task (pixma_sane_t * ss, int *exit_code) int status = 0; pid = ss->reader_taskid; - if (pid == -1) + if (!sanei_thread_is_valid (pid)) return -1; if (sanei_thread_is_forked ()) { @@ -1129,7 +1139,7 @@ start_reader_task (pixma_sane_t * ss) ss->rpipe = -1; ss->wpipe = -1; } - if (ss->reader_taskid != -1) + if (sanei_thread_is_valid (ss->reader_taskid)) { PDBG (pixma_dbg (1, "BUG:reader_taskid(%ld) != -1\n", (long) ss->reader_taskid)); @@ -1159,7 +1169,7 @@ start_reader_task (pixma_sane_t * ss) { pid = sanei_thread_begin (reader_thread, ss); } - if (pid == -1) + if (!sanei_thread_is_valid (pid)) { close (ss->wpipe); close (ss->rpipe); @@ -1227,7 +1237,7 @@ read_image (pixma_sane_t * ss, void *buf, unsigned size, int *readlen) ss->image_bytes_read, ss->sp.image_size)); close (ss->rpipe); ss->rpipe = -1; - if (terminate_reader_task (ss, &status) != -1 + if (sanei_thread_is_valid (terminate_reader_task (ss, &status)) && status != SANE_STATUS_GOOD) { return status; @@ -1371,6 +1381,7 @@ sane_open (SANE_String_Const name, SANE_Handle * h) ss->rpipe = -1; ss->idle = SANE_TRUE; ss->scanning = SANE_FALSE; + ss->sp.frontend_cancel = SANE_FALSE; for (j=0; j < BUTTON_GROUP_SIZE; j++) ss->button_option_is_cached[j] = 0; error = pixma_open (i, &ss->s); @@ -1620,6 +1631,7 @@ sane_cancel (SANE_Handle h) if (!ss) return; ss->cancel = SANE_TRUE; + ss->sp.frontend_cancel = SANE_TRUE; if (ss->idle) return; close (ss->rpipe); @@ -1812,6 +1824,13 @@ type int threshold-curve desc Dynamic threshold curve, from light to dark, normally 50-65 cap soft_select soft_detect automatic inactive +type int adf-wait + default 0 + constraint (0,3600,1) + title ADF Waiting Time + desc When set, the scanner searches the waiting time in seconds for a new document inserted into the automatic document feeder. + cap soft_select soft_detect automatic inactive + rem ------------------------------------------- END SANE_Option_Descriptor */ diff --git a/backend/pixma.conf.in b/backend/pixma.conf.in index a275b03..3f5c61a 100644 --- a/backend/pixma.conf.in +++ b/backend/pixma.conf.in @@ -1,5 +1,11 @@ # pixma.conf configuration for the sane pixma backend # +# bjnp-timeout=5000 +# Specify the timeout (in ms) to be used for all the folllowing +# scanners. +# May be specified multiple times. +# The last value (if any) will be used for auto-detection +# # define URI's of scanners (one per line) # This is only used for network scanners. # normally scanners will be detected by sending a broadcast @@ -8,7 +14,12 @@ # # method must be bjnp # port number can normally be left out, port 8612 is used as default +# The timeout parameter sets a timeout value for the scanner on +# the same line # Example: -# bjnp://myscanner.my.domain:8612 -# bjnp://printer-1.pheasant.org +# bjnp://myscanner.my.domain:8612 // uses the default 1000ms timeout +# bjnp-timeout=5000 +# bjnp://printer-1.pheasant.org // will use the 5000 ms timeout +# bjnp://scanner.bad-network.org/timeout=1500 // timeout set to 1500 ms +# bjnp-timeout=3000 // will be used for auto-detected scanners # diff --git a/backend/pixma.h b/backend/pixma.h index 620f038..6d723fb 100644 --- a/backend/pixma.h +++ b/backend/pixma.h @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -110,11 +110,14 @@ typedef uint32_t uint32_t; /** \addtogroup API * @{ */ +/** Don't forget to update the backend version in the SANE Backend specification + * file: doc/descriptions/pixma.desc !!! + */ /** \name Version of the driver */ /**@{*/ #define PIXMA_VERSION_MAJOR 0 #define PIXMA_VERSION_MINOR 17 -#define PIXMA_VERSION_BUILD 23 +#define PIXMA_VERSION_BUILD 37 /**@}*/ /** \name Error codes */ @@ -150,6 +153,7 @@ typedef uint32_t uint32_t; #define PIXMA_CAP_LINEART (1 << 9) #define PIXMA_CAP_NEGATIVE (1 << 10) #define PIXMA_CAP_TPUIR ((1 << 11) | PIXMA_CAP_TPU) +#define PIXMA_CAP_ADF_WAIT (1 << 12) #define PIXMA_CAP_EXPERIMENT (1 << 31) /**@}*/ @@ -337,6 +341,10 @@ struct pixma_scan_param_t /** The current page # in the same ADF scan session, 0 in non ADF */ unsigned adf_pageid; + + /** adf-wait */ + unsigned adf_wait; + unsigned frontend_cancel; }; /** PIXMA model information */ diff --git a/backend/pixma_bjnp.c b/backend/pixma_bjnp.c index 7d2d541..fc4c501 100644 --- a/backend/pixma_bjnp.c +++ b/backend/pixma_bjnp.c @@ -85,7 +85,7 @@ #ifdef HAVE_IFADDRS_H #include #endif -#ifdef HAVE_SYS_SELSECT_H +#ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_PWD_H @@ -395,18 +395,19 @@ determine_scanner_serial (const char *hostname, const char * mac_address, char * /* if we only have a literal ipv6 address, we use the mac-address */ strcpy(copy, hostname); - while (strlen (copy) >= SHORT_HOSTNAME_MAX) + if (strlen (copy) >= SERIAL_MAX) { + /* make the string fit into the serial */ /* if this is a FQDN, not an ip-address, remove domain part of the name */ if ((dot = strchr (copy, '.')) != NULL) { *dot = '\0'; } - else - { - strcpy(copy, mac_address); - break; - } + } + /* check if name is still to long. If so use the mac-address */ + if (strlen(copy) >= SERIAL_MAX) + { + strcpy(copy, mac_address); } strcpy( serial, copy ); return serial; @@ -566,6 +567,7 @@ split_uri (const char *devname, char *method, char *host, char *port, return -1; } strcpy(port, start); + start = end_of_port + 1; } /* @@ -613,7 +615,6 @@ set_cmd_for_dev (int devno, struct BJNP_command *cmd, char cmd_code, int payload /* * Set command buffer with command code, session_id and length of payload * Returns: sequence number of command - * If devno < 0, then use devno as negativ index into bjnp_protocol_defs */ strncpy (cmd->BJNP_id, device[devno].protocol_string, sizeof (cmd->BJNP_id)); @@ -706,8 +707,8 @@ udp_command (const int dev_no, char *command, int cmd_len, char *response, FD_ZERO (&fdset); FD_SET (sockfd, &fdset); - timeout.tv_sec = BJNP_TIMEOUT_UDP; - timeout.tv_usec = 0; + timeout.tv_sec = device[dev_no].bjnp_timeout /1000; + timeout.tv_usec = device[dev_no].bjnp_timeout %1000; } while (((result = select (sockfd + 1, &fdset, NULL, NULL, &timeout)) <= 0) @@ -737,7 +738,7 @@ udp_command (const int dev_no, char *command, int cmd_len, char *response, close(sockfd); PDBG (bjnp_dbg - (LOG_CRIT, "udp_command: ERROR - no data received\n" ) ); + (LOG_CRIT, "udp_command: ERROR - no data received (timeout = %d)\n", device[dev_no].bjnp_timeout ) ); return -1; } @@ -807,7 +808,7 @@ get_scanner_name(const bjnp_sockaddr_t *scanner_sa, char *host) { /* * Parse identify command responses to ip-address - * and hostname + * and hostname. Return qulity of the address */ struct addrinfo *results; @@ -1423,8 +1424,8 @@ bjnp_recv_header (int devno, size_t *payload_size ) FD_ZERO (&input); FD_SET (fd, &input); - timeout.tv_sec = BJNP_TIMEOUT_TCP; - timeout.tv_usec = 0; + timeout.tv_sec = device[devno].bjnp_timeout /1000; + timeout.tv_usec = device[devno].bjnp_timeout %1000; } while ( ( (result = select (fd + 1, &input, NULL, NULL, &timeout)) <= 0) && (errno == EINTR) && (attempt++ < BJNP_MAX_SELECT_ATTEMPTS)); @@ -1442,7 +1443,8 @@ bjnp_recv_header (int devno, size_t *payload_size ) { terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, - "bjnp_recv_header: ERROR - could not read response header (select timed out)!\n" ) ); + "bjnp_recv_header: ERROR - could not read response header (select timed out after %d ms)!\n", + device[devno].bjnp_timeout ) ); errno = terrno; return SANE_STATUS_IO_ERROR; } @@ -1502,7 +1504,7 @@ bjnp_recv_header (int devno, size_t *payload_size ) } static int -bjnp_init_device_structure(int dn, bjnp_sockaddr_t *sa, bjnp_protocol_defs_t *protocol_defs) +bjnp_init_device_structure(int dn, bjnp_sockaddr_t *sa, bjnp_protocol_defs_t *protocol_defs, int min_timeout) { /* initialize device structure */ @@ -1524,7 +1526,8 @@ bjnp_init_device_structure(int dn, bjnp_sockaddr_t *sa, bjnp_protocol_defs_t *pr device[dn].address_level = get_scanner_name(sa, name); device[dn].session_id = 0; device[dn].serial = -1; - device[dn].bjnp_timeout = 0; + device[dn].bjnp_timeout = min_timeout; + device[dn].bjnp_min_timeout = min_timeout; device[dn].scanner_data_left = 0; device[dn].last_cmd = 0; device[dn].blocksize = BJNP_BLOCKSIZE_START; @@ -1597,8 +1600,8 @@ bjnp_recv_data (int devno, SANE_Byte * buffer, size_t start_pos, size_t * len) /* wait for data to be received, retry on a signal being received */ FD_ZERO (&input); FD_SET (fd, &input); - timeout.tv_sec = BJNP_TIMEOUT_TCP; - timeout.tv_usec = 0; + timeout.tv_sec = device[devno].bjnp_timeout /1000; + timeout.tv_usec = device[devno].bjnp_timeout %1000; } while (((result = select (fd + 1, &input, NULL, NULL, &timeout)) <= 0) && (errno == EINTR) && (attempt++ < BJNP_MAX_SELECT_ATTEMPTS)); @@ -1617,7 +1620,8 @@ bjnp_recv_data (int devno, SANE_Byte * buffer, size_t start_pos, size_t * len) { terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, - "bjnp_recv_data: ERROR - could not read response payload (select timed out)!\n") ); + "bjnp_recv_data: ERROR - could not read response payload (select timed out after %d ms)!\n", + device[devno].bjnp_timeout) ); errno = terrno; *len = 0; return SANE_STATUS_IO_ERROR; @@ -1643,7 +1647,7 @@ bjnp_recv_data (int devno, SANE_Byte * buffer, size_t start_pos, size_t * len) static BJNP_Status bjnp_allocate_device (SANE_String_Const devname, - SANE_Int * dn, char *res_host) + SANE_Int * dn, char *resulting_host) { char method[BJNP_METHOD_MAX]; char host[BJNP_HOST_MAX]; @@ -1654,6 +1658,7 @@ bjnp_allocate_device (SANE_String_Const devname, struct addrinfo hints; int result; int i; + int min_timeout = BJNP_TIMEOUT_DEFAULT; PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_allocate_device(%s) %d\n", devname, bjnp_no_devices)); @@ -1662,20 +1667,29 @@ bjnp_allocate_device (SANE_String_Const devname, return BJNP_STATUS_INVAL; } - if (strlen (args) != 0) + if (strlen (args) > 0) { - PDBG (bjnp_dbg - (LOG_CRIT, - "bjnp_allocate_device: ERROR - URI may not contain userid, password or aguments: %s\n", - devname)); + /* get device specific timeout if any */ + + if (strncmp(args, "timeout=", strlen("timeout=")) == 0) + { + min_timeout = atoi(args + strlen("timeout=")); + if (min_timeout < BJNP_TIMEOUT_DEFAULT) + min_timeout = BJNP_TIMEOUT_DEFAULT; + } else { + PDBG (bjnp_dbg + (LOG_CRIT, + "bjnp_allocate_device: ERROR - Unrecognized argument: %s\n", + devname)); return BJNP_STATUS_INVAL; + } } if ( (protocol_defs = get_protocol_by_method(method)) == NULL) { PDBG (bjnp_dbg - (LOG_CRIT, "bjnp_allocate_device: ERROR - URI %s contains invalid method: %s\n", devname, - method)); + (LOG_CRIT, "bjnp_allocate_device: ERROR - URI %s contains invalid method: %s\n", + devname, method)); return BJNP_STATUS_INVAL; } @@ -1715,24 +1729,26 @@ bjnp_allocate_device (SANE_String_Const devname, { PDBG (bjnp_dbg (LOG_CRIT, - "bjnp_allocate_device: WARNING - Too many devices, ran out of device structures, can not add %s\n", + "bjnp_allocate_device: WARNING - Too many devices, ran out of device structures, cannot add %s\n", devname)); freeaddrinfo(res); return BJNP_STATUS_INVAL; } if (bjnp_init_device_structure( bjnp_no_devices, (bjnp_sockaddr_t *)cur -> ai_addr, - protocol_defs) != 0) + protocol_defs, min_timeout) != 0) { /* giving up on this address, try next one if any */ break; } for (i = 0; i < bjnp_no_devices; i++) { - /* we check for matching addresses as wel as matching mac_addresses as */ - /* an IPv6 host can have multiple adresses */ - if ( (sa_is_equal( device[i].addr, (bjnp_sockaddr_t *)cur -> ai_addr) ) || - ( strcmp( device[i].mac_address, device[bjnp_no_devices].mac_address ) == 0 ) ) + /* Check if found the scanner before, if so we use the best address + * but still make sure the scanner is listed only once. + * We check for matching addresses as wel as matching mac_addresses as + * an IPv6 host can have multiple adresses */ + + if ( strcmp( device[i].mac_address, device[bjnp_no_devices].mac_address ) == 0 ) { if ( device[i].address_level < device[bjnp_no_devices].address_level ) { @@ -1742,6 +1758,16 @@ bjnp_allocate_device (SANE_String_Const devname, device[bjnp_no_devices].addr = NULL; device[i].address_level = device[bjnp_no_devices].address_level; } + + /* check if new timeout value was defined (e.g. from sanei_bjnp_device_open) + * if so, use new timout value */ + + if (device[i].bjnp_min_timeout < device[bjnp_no_devices].bjnp_min_timeout) + { + /* use the longer timeout as requested */ + device[i].bjnp_timeout = device[bjnp_no_devices].bjnp_min_timeout; + device[i].bjnp_min_timeout = device[bjnp_no_devices].bjnp_min_timeout; + } freeaddrinfo(res); *dn = i; bjnp_free_device_structure( bjnp_no_devices); @@ -1754,17 +1780,17 @@ bjnp_allocate_device (SANE_String_Const devname, PDBG (bjnp_dbg (LOG_INFO, "bjnp_allocate_device: Scanner not yet in our list, added it: %s:%s\n", host, port)); - /* return hostname if required */ + /* Commit new device structure */ - if (res_host != NULL) - { - strcpy (res_host, host); - } *dn = bjnp_no_devices; + bjnp_no_devices++; - /* Commit new device structure */ + /* return hostname if required */ - bjnp_no_devices++; + if (resulting_host != NULL) + { + strcpy (resulting_host, host); + } return BJNP_STATUS_GOOD; } @@ -1800,10 +1826,11 @@ static void add_scanner(SANE_Int *dev_no, */ determine_scanner_serial (scanner_host, device[*dev_no].mac_address, serial); + attach_bjnp (uri, makemodel, serial, pixma_devices); - PDBG (bjnp_dbg (LOG_NOTICE, "add_scanner: New scanner at %s added!\n", - uri)); + PDBG (bjnp_dbg (LOG_NOTICE, "add_scanner: New scanner added: %s, serial %s, mac addres: %s.\n", + uri, serial, device[*dev_no].mac_address)); } break; case BJNP_STATUS_ALREADY_ALLOCATED: @@ -1818,6 +1845,34 @@ static void add_scanner(SANE_Int *dev_no, } } +int rewrite_uri(char *uri, int timeout, int max_len) +{ + char method[BJNP_METHOD_MAX]; + char host[BJNP_HOST_MAX]; + char port_str[BJNP_PORT_MAX]; + char args[BJNP_HOST_MAX]; + int port; + + if (split_uri(uri, method, host, port_str, args ) != 0) + { + return -1; + } + + port = atoi(port_str); + if (port == 0) + { + port = 8612; + } + + if (strstr(args, "timeout=") == NULL) + { + sprintf(args, "timeout=%d", timeout); + } + + snprintf(uri, max_len -1, "bjnp://%s:%d/%s", host, port, args); + return 0; +} + /* * Public functions @@ -1870,6 +1925,7 @@ sanei_bjnp_find_devices (const char **conf_devices, char uri[256]; int dev_no; int port; + int timeout_default = BJNP_TIMEOUT_DEFAULT; bjnp_sockaddr_t broadcast_addr[BJNP_SOCK_MAX]; bjnp_sockaddr_t scanner_sa; socklen_t socklen; @@ -1885,16 +1941,30 @@ sanei_bjnp_find_devices (const char **conf_devices, { socket_fd[i] = -1; } - /* First add devices from config file */ + + /* Add devices from config file */ if (conf_devices[0] == NULL) PDBG (bjnp_dbg( LOG_DEBUG, "sanei_bjnp_find_devices: No devices specified in configuration file.\n" ) ); for (i = 0; conf_devices[i] != NULL; i++) { + if (strncmp(conf_devices[i], "bjnp-timeout=", strlen("bjnp-timeout="))== 0) + { + timeout_default = atoi(conf_devices[i] + strlen("bjnp-timeout=") ); + if (timeout_default < BJNP_TIMEOUT_DEFAULT) + { + timeout_default = BJNP_TIMEOUT_DEFAULT; + } + PDBG ( bjnp_dbg + (LOG_DEBUG, "Set new default timeout value: %d ms.", timeout_default)); + continue; + } PDBG (bjnp_dbg (LOG_DEBUG, "sanei_bjnp_find_devices: Adding scanner from pixma.conf: %s\n", conf_devices[i])); - add_scanner(&dev_no, conf_devices[i], attach_bjnp, pixma_devices); + strncpy(uri, conf_devices[i], sizeof(uri)); + rewrite_uri(uri, timeout_default, sizeof(uri)); + add_scanner(&dev_no, uri, attach_bjnp, pixma_devices); } PDBG (bjnp_dbg (LOG_DEBUG, @@ -2062,8 +2132,8 @@ sanei_bjnp_find_devices (const char **conf_devices, get_scanner_name( &scanner_sa, scanner_host); /* construct URI */ - sprintf (uri, "%s://%s:%d", protocol_defs->method_string, scanner_host, - port); + sprintf (uri, "%s://%s:%d/timeout=%d", protocol_defs->method_string, scanner_host, + port, timeout_default); add_scanner( &dev_no, uri, attach_bjnp, pixma_devices); @@ -2182,8 +2252,15 @@ sanei_bjnp_deactivate (SANE_Int dn) extern void sanei_bjnp_set_timeout (SANE_Int devno, SANE_Int timeout) { - PDBG (bjnp_dbg (LOG_INFO, "bjnp_set_timeout to %d\n", + if (timeout < device[devno].bjnp_min_timeout) + { + PDBG (bjnp_dbg (LOG_INFO, "bjnp_set_timeout to %d, but using minimum value %d\n", + timeout, device[devno].bjnp_min_timeout)); + timeout = device[devno].bjnp_min_timeout; + } else { + PDBG (bjnp_dbg (LOG_INFO, "bjnp_set_timeout to %d\n", timeout)); + } device[devno].bjnp_timeout = timeout; } @@ -2460,16 +2537,6 @@ sanei_bjnp_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) if ( resp_len > 0 ) { device[dn].polling_status = BJNP_POLL_STATUS_RECEIVED; - - /* this is a bit of a hack, but the scanner does not like */ - /* us to continue using the existing tcp socket */ - - /* No longer required? Does not work anymore now we moved code from sanei_bjnp_activate/sanei_bjnp_deactivate - to the isanei_bjnp_open and sanei_bjnp_close - sanei_bjnp_deactivate(dn); - sanei_bjnp_activate(dn); - */ - return SANE_STATUS_GOOD; } seconds = timeout > 2 ? 2 : timeout; diff --git a/backend/pixma_bjnp.h b/backend/pixma_bjnp.h index 3770bfd..998c331 100644 --- a/backend/pixma_bjnp.h +++ b/backend/pixma_bjnp.h @@ -65,9 +65,10 @@ extern void sanei_bjnp_init (void); /** Find scanners responding to a BJNP broadcast. * - * The function attach is called for every device which has been found. + * The function sanei_bjnp_attach is called for every device which has + * been found. * Serial is the address of the scanner in human readable form of max - * SHORT_HOSTNAME_MAX characters + * SERIAL_MAX characters * @param conf_devices list of pre-configures device URI's to attach * @param attach attach function * @param pixma_devices device informatio needed by attach function @@ -75,7 +76,7 @@ extern void sanei_bjnp_init (void); * @return SANE_STATUS_GOOD - on success (even if no scanner was found) */ -#define SHORT_HOSTNAME_MAX 16 +#define SERIAL_MAX 16 extern SANE_Status sanei_bjnp_find_devices (const char **conf_devices, diff --git a/backend/pixma_bjnp_private.h b/backend/pixma_bjnp_private.h index 1902c7a..9ecc6ae 100644 --- a/backend/pixma_bjnp_private.h +++ b/backend/pixma_bjnp_private.h @@ -80,8 +80,7 @@ /* timers */ #define BJNP_BROADCAST_INTERVAL 10 /* ms between broadcasts */ #define BJNP_BC_RESPONSE_TIMEOUT 500 /* waiting time for broadc. responses */ -#define BJNP_TIMEOUT_UDP 4 /* standard UDP timeout in seconds */ -#define BJNP_TIMEOUT_TCP 4 /* standard TCP timeout in seconds */ +#define BJNP_TIMEOUT_DEFAULT 1000 /* minimum tiemout value for network operations */ #define BJNP_USLEEP_MS 1000 /* sleep for 1 msec */ /* retries */ @@ -371,6 +370,7 @@ typedef struct device_s bjnp_sockaddr_t * addr; /* ip-address of the scanner */ int address_level; /* link local, public or has a FQDN */ int bjnp_timeout; /* timeout (msec) for next poll command */ + int bjnp_min_timeout; /* device specific min timeout */ #ifdef PIXMA_BJNP_USE_STATUS /* polling state information */ diff --git a/backend/pixma_common.c b/backend/pixma_common.c index 9d41f7a..2882453 100644 --- a/backend/pixma_common.c +++ b/backend/pixma_common.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -57,6 +57,8 @@ #include "pixma_common.h" #include "pixma_io.h" +#include "../include/sane/sanei_usb.h" + #ifdef __GNUC__ # define UNUSED(v) (void) v @@ -649,15 +651,21 @@ pixma_cmd_transaction (pixma_t * s, const void *cmd, unsigned cmdlen, immediatly answer with PIXMA_STATUS_BUSY. Is 8 seconds timeout enough? This affects ALL commands that use - pixma_cmd_transaction(). */ - tmo = 8; + pixma_cmd_transaction(). Default value set in pixma_open(). */ + tmo = s->rec_tmo; do { error = pixma_read (s->io, data, expected_len); if (error == PIXMA_ETIMEDOUT) { PDBG (pixma_dbg (2, "No response yet. Timed out in %d sec.\n", tmo)); - pixma_sleep (1000000); /* 1s timeout */ + +#ifndef HAVE_SANEI_USB_SET_TIMEOUT + /* 1s timeout + Only needed, if sanei_usb_set_timeout() isn't available. + pixma_read() has an internal timeout of 1 sec. */ + pixma_sleep (1000000); +#endif } } while (error == PIXMA_ETIMEDOUT && --tmo != 0); @@ -761,6 +769,7 @@ pixma_open (unsigned devnr, pixma_t ** handle) first_pixma = s; s->cfg = cfg; + s->rec_tmo = 8; /* set receive timeout to 8 seconds */ error = pixma_connect (devnr, &s->io); if (error < 0) { @@ -839,6 +848,7 @@ pixma_scan (pixma_t * s, pixma_scan_param_t * sp) sp->xdpi, sp->ydpi, sp->x, sp->y, sp->w, sp->h); pixma_dbg (3, " gamma_table=%p source=%d\n", sp->gamma_table, sp->source); pixma_dbg (3, " threshold=%d threshold_curve=%d\n", sp->threshold, sp->threshold_curve); + pixma_dbg (3, " adf-wait=%d\n", sp->adf_wait); pixma_dbg (3, " ADF page count: %d\n", sp->adf_pageid); #endif diff --git a/backend/pixma_common.h b/backend/pixma_common.h index dbaa23f..6c55c71 100644 --- a/backend/pixma_common.h +++ b/backend/pixma_common.h @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2006-2007 Wittawat Yamwong This file is part of the SANE package. @@ -118,6 +118,7 @@ struct pixma_t int cancel; /* NOTE: It can be set in a signal handler. */ uint32_t events; void *subdriver; /* can be used by model driver. */ + int rec_tmo; /* receive timeout [s] */ /* private */ uint64_t cur_image_size; diff --git a/backend/pixma_imageclass.c b/backend/pixma_imageclass.c index b2d45ee..8ad0083 100644 --- a/backend/pixma_imageclass.c +++ b/backend/pixma_imageclass.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2008 Dennis Lou, dlou 99 at yahoo dot com @@ -103,6 +103,8 @@ #define MF820_PID 0x27a6 #define MF220_PID 0x27a8 #define MF210_PID 0x27a9 +#define MF230_PID 0x27d1 +#define MF240_PID 0x27d2 enum iclass_state_t @@ -140,9 +142,22 @@ typedef struct iclass_t unsigned last_block; uint8_t generation; /* New multifunctionals are (generation == 2) */ + + uint8_t adf_state; /* handle adf scanning */ } iclass_t; +static int is_scanning_from_adf (pixma_t * s) +{ + return (s->param->source == PIXMA_SOURCE_ADF + || s->param->source == PIXMA_SOURCE_ADFDUP); +} + +static int is_scanning_from_adfdup (pixma_t * s) +{ + return (s->param->source == PIXMA_SOURCE_ADFDUP); +} + static void iclass_finish_scan (pixma_t * s); /* checksumming is sometimes different than pixmas */ @@ -163,7 +178,8 @@ static int has_paper (pixma_t * s) { iclass_t *mf = (iclass_t *) s->subdriver; - return ((mf->current_status[1] & 0x0f) == 0); /* allow 0x10 as ADF paper OK */ + return ((mf->current_status[1] & 0x0f) == 0 /* allow 0x10 as ADF paper OK */ + || mf->current_status[1] == 81); /* allow 0x51 as ADF paper OK */ } static int @@ -185,9 +201,9 @@ query_status (pixma_t * s) if (error >= 0) { memcpy (mf->current_status, data, 12); - DBG (3, "Current status: paper=%u cal=%u lamp=%u\n", - data[1], data[8], data[7]); - PDBG (pixma_dbg (3, "Current status: paper=%u cal=%u lamp=%u\n", + /*DBG (3, "Current status: paper=0x%02x cal=%u lamp=%u\n", + data[1], data[8], data[7]);*/ + PDBG (pixma_dbg (3, "Current status: paper=0x%02x cal=%u lamp=%u\n", data[1], data[8], data[7])); } return error; @@ -229,9 +245,9 @@ select_source (pixma_t * s) { iclass_t *mf = (iclass_t *) s->subdriver; uint8_t *data = pixma_newcmd (&mf->cb, cmd_select_source, 10, 0); - data[0] = (s->param->source == PIXMA_SOURCE_ADF || - s->param->source == PIXMA_SOURCE_ADFDUP) ? 2 : 1; - data[5] = (s->param->source == PIXMA_SOURCE_ADFDUP) ? 3 : 0; + data[0] = (is_scanning_from_adf(s)) ? 2 : 1; + /* special settings for MF6100 */ + data[5] = is_scanning_from_adfdup(s) ? 3 : ((s->cfg->pid == MF6100_PID && s->param->source == PIXMA_SOURCE_ADF) ? 1 : 0); switch (s->cfg->pid) { case MF4200_PID: @@ -263,7 +279,7 @@ send_scan_param (pixma_t * s) pixma_set_be32 (mf->raw_width, data + 0x10); pixma_set_be32 (s->param->h, data + 0x14); data[0x18] = (s->param->channels == 1) ? 0x04 : 0x08; - data[0x19] = s->param->channels * s->param->depth; /* bits per pixel */ + data[0x19] = s->param->channels * ((s->param->depth == 1) ? 8 : s->param->depth); /* bits per pixel */ data[0x1f] = 0x7f; data[0x20] = 0xff; data[0x23] = 0x81; @@ -294,7 +310,10 @@ request_image_block (pixma_t * s, unsigned flag, uint8_t * info, const int hlen = 2 + 6; memset (mf->cb.buf, 0, 11); - pixma_set_be16 (((mf->generation >= 2) ? cmd_read_image2 : cmd_read_image), mf->cb.buf); + /* generation 2 scanners use cmd_read_image2. + * MF6100, ... are exceptions */ + pixma_set_be16 (((mf->generation >= 2 + && s->cfg->pid != MF6100_PID) ? cmd_read_image2 : cmd_read_image), mf->cb.buf); mf->cb.buf[8] = flag; mf->cb.buf[10] = 0x06; expected_len = (mf->generation >= 2 || @@ -419,13 +438,46 @@ static int step1 (pixma_t * s) { int error; + int rec_tmo; iclass_t *mf = (iclass_t *) s->subdriver; + /* don't wait full timeout for 1st command */ + rec_tmo = s->rec_tmo; /* save globel timeout */ + s->rec_tmo = 2; /* set timeout to 2 seconds */ error = query_status (s); + s->rec_tmo = rec_tmo; /* restore global timeout */ + if (error < 0) + { + PDBG (pixma_dbg (1, "WARNING: Resend first USB command after timeout!\n")); + error = query_status (s); + } if (error < 0) return error; - if (s->param->source == PIXMA_SOURCE_ADF && !has_paper (s)) + + /* wait for inserted paper */ + if (s->param->adf_wait != 0 && is_scanning_from_adf(s)) + { + int tmo = s->param->adf_wait; + + while (!has_paper (s) && --tmo >= 0 && !s->param->frontend_cancel) + { + if ((error = query_status (s)) < 0) + return error; + pixma_sleep (1000000); + PDBG (pixma_dbg(2, "No paper in ADF. Timed out in %d sec.\n", tmo)); + } + /* canceled from frontend */ + if (s->param->frontend_cancel) + { + return PIXMA_ECANCELED; + } + } + /* no paper inserted + * => abort session */ + if (is_scanning_from_adf(s) && !has_paper (s)) + { return PIXMA_ENO_PAPER; + } /* activate only seen for generation 1 scanners */ if (mf->generation == 1) { @@ -484,6 +536,9 @@ iclass_open (pixma_t * s) mf->cb.cmd_header_len = 10; mf->cb.cmd_len_field_ofs = 7; + /* adf scanning */ + mf->adf_state = state_idle; + /* set generation = 2 for new multifunctionals */ mf->generation = (s->cfg->pid >= MF8030_PID) ? 2 : 1; PDBG (pixma_dbg (3, "*iclass_open***** This is a generation %d scanner. *****\n", mf->generation)); @@ -513,8 +568,34 @@ iclass_check_param (pixma_t * s, pixma_scan_param_t * sp) { UNUSED (s); + /* PDBG (pixma_dbg (4, "*iclass_check_param***** Initially: channels=%u, depth=%u, x=%u, y=%u, w=%u, line_size=%" PRIu64 " , h=%u*****\n", + sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->line_size, sp->h)); */ + sp->depth = 8; - sp->line_size = ALIGN_SUP (sp->w, 32) * sp->channels; + sp->software_lineart = 0; + if (sp->mode == PIXMA_SCAN_MODE_LINEART) + { + sp->software_lineart = 1; + sp->channels = 1; + sp->depth = 1; + } + + if (sp->software_lineart == 1) + { + unsigned w_max; + + /* for software lineart line_size and w must be a multiple of 8 */ + sp->line_size = ALIGN_SUP (sp->w, 8) * sp->channels; + sp->w = ALIGN_SUP (sp->w, 8); + + /* do not exceed the scanner capability */ + w_max = s->cfg->width * s->cfg->xdpi / 75; + w_max -= w_max % 32; + if (sp->w > w_max) + sp->w = w_max; + } + else + sp->line_size = ALIGN_SUP (sp->w, 32) * sp->channels; /* Some exceptions here for particular devices */ /* Those devices can scan up to Legal 14" with ADF, but A4 11.7" in flatbed */ @@ -522,6 +603,9 @@ iclass_check_param (pixma_t * s, pixma_scan_param_t * sp) if ((s->cfg->cap & PIXMA_CAP_ADF) && sp->source == PIXMA_SOURCE_FLATBED) sp->h = MIN (sp->h, 877 * sp->xdpi / 75); + /* PDBG (pixma_dbg (4, "*iclass_check_param***** Finally: channels=%u, depth=%u, x=%u, y=%u, w=%u, line_size=%" PRIu64 " , h=%u*****\n", + sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->line_size, sp->h)); */ + return 0; } @@ -559,7 +643,8 @@ iclass_scan (pixma_t * s) mf->blk_len = 0; error = step1 (s); - if (error >= 0 && (s->param->adf_pageid == 0 || mf->generation == 1)) + if (error >= 0 + && (s->param->adf_pageid == 0 || mf->generation == 1 || mf->adf_state == state_idle)) { /* single sheet or first sheet from ADF */ PDBG (pixma_dbg (3, "*iclass_scan***** start scanning *****\n")); error = start_session (s); @@ -583,6 +668,10 @@ iclass_scan (pixma_t * s) return error; } mf->last_block = 0; + + /* ADF scanning active */ + if (is_scanning_from_adf (s)) + mf->adf_state = state_scanning; return 0; } @@ -592,7 +681,7 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) { int error, n; iclass_t *mf = (iclass_t *) s->subdriver; - unsigned block_size, lines_size, first_block_size; + unsigned block_size, lines_size, lineart_lines_size, first_block_size; uint8_t info; /* @@ -652,10 +741,33 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) /* add current block to remainder of previous */ mf->blk_len += block_size; /* n = number of full lines (rows) we have in the buffer. */ - n = mf->blk_len / s->param->line_size; + n = mf->blk_len / ((s->param->mode == PIXMA_SCAN_MODE_LINEART) ? mf->raw_width : s->param->line_size); if (n != 0) { - if (s->param->channels != 1 && + /* PDBG (pixma_dbg (4, "*iclass_fill_buffer***** Processing with n=%d, w=%i, line_size=%" PRIu64 ", raw_width=%u ***** \n", + n, s->param->w, s->param->line_size, mf->raw_width)); */ + /* PDBG (pixma_dbg (4, "*iclass_fill_buffer***** scan_mode=%d, lineptr=%" PRIu64 ", blkptr=%" PRIu64 " \n", + s->param->mode, (uint64_t)mf->lineptr, (uint64_t)mf->blkptr)); */ + + /* gray to lineart convert + * mf->lineptr : image line + * mf->blkptr : scanned image block as grayscale + * s->param->w : image width + * s->param->line_size : scanned image width */ + if (s->param->mode == PIXMA_SCAN_MODE_LINEART) + { + int i; + uint8_t *sptr, *dptr; + + /* PDBG (pixma_dbg (4, "*iclass_fill_buffer***** Processing lineart *****\n")); */ + + /* process ALL lines */ + sptr = mf->blkptr; + dptr = mf->lineptr; + for (i = 0; i < n; i++, sptr += mf->raw_width) + dptr = pixma_binarize_line (s->param, dptr, sptr, s->param->line_size, 1); + } + else if (s->param->channels != 1 && mf->generation == 1 && s->cfg->pid != MF4600_PID && s->cfg->pid != MF6500_PID && @@ -669,17 +781,22 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) /* grayscale */ memcpy (mf->lineptr, mf->blkptr, n * s->param->line_size); } - lines_size = n * s->param->line_size; /* cull remainder and shift left */ + lineart_lines_size = n * s->param->line_size / 8; + lines_size = n * ((s->param->mode == PIXMA_SCAN_MODE_LINEART) ? mf->raw_width : s->param->line_size); mf->blk_len -= lines_size; memcpy (mf->blkptr, mf->blkptr + lines_size, mf->blk_len); } } while (n == 0); - /* output full lines, keep partial lines for next block */ + /* output full lines, keep partial lines for next block + * ib->rptr : start of image buffer + * ib->rend : end of image buffer */ ib->rptr = mf->lineptr; - ib->rend = mf->lineptr + lines_size; + ib->rend = mf->lineptr + (s->param->mode == PIXMA_SCAN_MODE_LINEART ? lineart_lines_size : lines_size); + /* PDBG (pixma_dbg (4, "*iclass_fill_buffer***** rptr=%" PRIu64 ", rend=%" PRIu64 ", diff=%ld \n", + (uint64_t)ib->rptr, (uint64_t)ib->rend, ib->rend - ib->rptr)); */ return ib->rend - ib->rptr; } @@ -718,8 +835,17 @@ iclass_finish_scan (pixma_t * s) || (mf->generation == 1 && mf->last_block == 0x28) /* generation 1 scanner last block */ || (mf->generation >= 2 && !has_paper(s))) /* check status: no paper in ADF */ { + /* ADFDUP scan: wait for 8sec to throw last page out of ADF feeder */ + if (is_scanning_from_adfdup(s)) + { + PDBG (pixma_dbg (4, "*iclass_finish_scan***** sleep for 8s *****\n")); + pixma_sleep(8000000); /* sleep for 8s */ + query_status (s); + } PDBG (pixma_dbg (3, "*iclass_finish_scan***** abort session *****\n")); abort_session (s); + mf->adf_state = state_idle; + mf->last_block = 0; } else PDBG (pixma_dbg (3, "*iclass_finish_scan***** wait for next page from ADF *****\n")); @@ -777,6 +903,8 @@ static const pixma_scan_ops_t pixma_iclass_ops = { adftpu_max_dpi, /* adftpu_max_dpi */ \ 0, 0, /* tpuir_min_dpi & tpuir_max_dpi not used in this subdriver */ \ w, h, /* width, height */ \ + PIXMA_CAP_LINEART| /* all scanners have software lineart */ \ + PIXMA_CAP_ADF_WAIT| /* adf wait for all ADF and ADFDUP scanners */ \ PIXMA_CAP_GRAY|PIXMA_CAP_EVENTS|cap \ } const pixma_config_t pixma_iclass_devices[] = { @@ -809,9 +937,11 @@ const pixma_config_t pixma_iclass_devices[] = { DEV ("Canon imageRUNNER 1133", "iR1133", IR1133_PID, 600, 0, 637, 877, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF5900 Series", "MF5900", MF5900_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF8500C Series", "MF8500C", MF8500_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), - DEV ("Canon i-SENSYS MF6100 Series", "MF6100", MF6100_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), + DEV ("Canon i-SENSYS MF6100 Series", "MF6100", MF6100_PID, 600, 300, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon imageClass MF810/820", "MF810/820", MF820_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF220 Series", "MF220", MF220_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF210 Series", "MF210", MF210_PID, 600, 0, 640, 1050, PIXMA_CAP_ADF), + DEV ("Canon i-SENSYS MF230 Series", "MF230", MF230_PID, 600, 0, 640, 1050, PIXMA_CAP_ADF), + DEV ("Canon i-SENSYS MF240 Series", "MF240", MF240_PID, 600, 0, 640, 1050, PIXMA_CAP_ADF), DEV (NULL, NULL, 0, 0, 0, 0, 0, 0) }; diff --git a/backend/pixma_io.h b/backend/pixma_io.h index 004e008..9dc1afb 100644 --- a/backend/pixma_io.h +++ b/backend/pixma_io.h @@ -57,9 +57,9 @@ */ /** Timeout for pixma_read() in milliseconds */ -#define PIXMA_BULKIN_TIMEOUT 20000 +#define PIXMA_BULKIN_TIMEOUT 1000 /** Timeout for pixma_write() in milliseconds */ -#define PIXMA_BULKOUT_TIMEOUT 20000 +#define PIXMA_BULKOUT_TIMEOUT 1000 struct pixma_io_t; diff --git a/backend/pixma_io_sanei.c b/backend/pixma_io_sanei.c index 9e4a2fa..8eec883 100644 --- a/backend/pixma_io_sanei.c +++ b/backend/pixma_io_sanei.c @@ -1,7 +1,7 @@ /* SANE - Scanner Access Now Easy. * For limitations, see function sanei_usb_get_vendor_product(). - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2006-2007 Wittawat Yamwong This file is part of the SANE package. diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c index 4f8b232..dca0965 100644 --- a/backend/pixma_mp150.c +++ b/backend/pixma_mp150.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -228,7 +228,19 @@ #define MX490_PID 0x1787 #define E480_PID 0x1789 #define MG3600_PID 0x178a - +#define MG7700_PID 0x178b +#define MG6900_PID 0x178c +#define MG6800_PID 0x178d +#define MG5700_PID 0x178e + +/* 2016 new devices (untested) */ +#define TS9000_PID 0x179f +#define TS8000_PID 0x1800 +#define TS6000_PID 0x1801 +#define TS5000_PID 0x1802 +#define MG3000_PID 0x180b +#define E470_PID 0x180c +#define G3000_PID 0x181d /* Generation 4 XML messages that encapsulates the Pixma protocol messages */ #define XML_START_1 \ @@ -824,6 +836,7 @@ query_status (pixma_t * s) return error; } +#if 0 static int send_time (pixma_t * s) { @@ -843,6 +856,7 @@ send_time (pixma_t * s) PDBG (pixma_dbg (3, "Sending time: '%s'\n", (char *) data)); return pixma_exec (s, &mp->cb); } +#endif /* TODO: Simplify this function. Read the whole data packet in one shot. */ static int @@ -945,11 +959,13 @@ handle_interrupt (pixma_t * s, int timeout) * tt: target * rr: scan resolution * poll event with 'scanimage -A' */ - if (s->cfg->pid == MG6200_PID + if (s->cfg->pid == MG5400_PID + || s->cfg->pid == MG6200_PID || s->cfg->pid == MG6300_PID || s->cfg->pid == MX520_PID || s->cfg->pid == MX720_PID - || s->cfg->pid == MX920_PID) + || s->cfg->pid == MX920_PID + || s->cfg->pid == MB5000_PID) /* button no. in buf[7] * size in buf[10] 01=A4; 02=Letter; 08=10x15; 09=13x18; 0b=auto * format in buf[11] 01=JPEG; 02=TIFF; 03=PDF; 04=Kompakt-PDF @@ -968,7 +984,10 @@ handle_interrupt (pixma_t * s, int timeout) { /* More than one event can be reported at the same time. */ if (buf[3] & 1) + /* FIXME: This function makes trouble with a lot of scanners send_time (s); + */ + PDBG (pixma_dbg (1, "WARNING:send_time() disabled!\n")); if (buf[9] & 2) query_status (s); if (buf[0] & 2) @@ -1150,13 +1169,17 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) && s->cfg->pid != MX920_PID && s->cfg->pid != MG3100_PID && s->cfg->pid != MG3500_PID + && s->cfg->pid != MG3600_PID && s->cfg->pid != MG2100_PID && s->cfg->pid != MG5300_PID + && s->cfg->pid != MG5400_PID && s->cfg->pid != MG5500_PID && s->cfg->pid != MG6300_PID && s->cfg->pid != MG6400_PID && s->cfg->pid != MG7100_PID - && s->cfg->pid != MG7500_PID) + && s->cfg->pid != MG7500_PID + && s->cfg->pid != MG7700_PID + && s->cfg->pid != MB5000_PID) reorder_pixels (mp->linebuf, sptr, c, n, m, s->param->wx, line_size); /* Crop line to selected borders */ @@ -1828,6 +1851,19 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MX490 Series", "MX490", MX490_PID, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA E480 Series", "E480", E480_PID, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MG3600 Series", "MG3600", MG3600_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG7700 Series", "MG7700", MG7700_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG6900 Series", "MG6900", MG6900_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG6800 Series", "MG6800", MG6800_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG5700 Series", "MG5700", MG5700_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + + /* Latest devices (2016) Generation 4 CIS */ + DEVICE ("Canon PIXMA TS9000 Series", "TS9000", TS9000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8000 Series", "TS8000", TS8000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6000 Series", "TS6000", TS6000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS5000 Series", "TS5000", TS5000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG3000 Series", "MG3000", MG3000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA E470 Series", "E470", E470_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G4000 Series", "G3000", G3000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), END_OF_DEVICE_LIST }; diff --git a/backend/pixma_mp730.c b/backend/pixma_mp730.c index 2184ff7..6bf3f42 100644 --- a/backend/pixma_mp730.c +++ b/backend/pixma_mp730.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -63,13 +63,17 @@ #define IMAGE_BLOCK_SIZE (0xc000) #define CMDBUF_SIZE 512 +#define MP10_PID 0x261f + #define MP730_PID 0x262f #define MP700_PID 0x2630 +#define MP5_PID 0x2635 /* untested */ + #define MP360_PID 0x263c #define MP370_PID 0x263d #define MP390_PID 0x263e -#define MP375R_PID 0x263f /* untested */ +#define MP375R_PID 0x263f /* untested */ #define MP740_PID 0x264c /* Untested */ #define MP710_PID 0x264d @@ -341,6 +345,8 @@ handle_interrupt (pixma_t * s, int timeout) s->events = PIXMA_EV_BUTTON1; /* color scan */ break; + case MP5_PID: + case MP10_PID: case MP700_PID: case MP730_PID: case MP710_PID: @@ -453,6 +459,10 @@ step1 (pixma_t * s) default: break; } + + // ignore result from calibrate() + // don't interrupt @ PIXMA_STATUS_BUSY + error = 0; } if (error >= 0) error = activate (s, 0); @@ -537,7 +547,9 @@ calc_raw_width (pixma_t * s, const pixma_scan_param_t * sp) { if (sp->depth == 8) /* grayscale */ { - if (s->cfg->pid == MP700_PID || + if (s->cfg->pid == MP5_PID || + s->cfg->pid == MP10_PID || + s->cfg->pid == MP700_PID || s->cfg->pid == MP730_PID || s->cfg->pid == MP360_PID || s->cfg->pid == MP370_PID || @@ -566,8 +578,10 @@ mp730_check_param (pixma_t * s, pixma_scan_param_t * sp) { sp->depth=8; } - /* for MP360/370, MP700/730 in grayscale & lineart modes, max scan res is 600 dpi */ - if (s->cfg->pid == MP700_PID || + /* for MP5, MP10, MP360/370, MP700/730 in grayscale & lineart modes, max scan res is 600 dpi */ + if (s->cfg->pid == MP5_PID || + s->cfg->pid == MP10_PID || + s->cfg->pid == MP700_PID || s->cfg->pid == MP730_PID || s->cfg->pid == MP360_PID || s->cfg->pid == MP370_PID || @@ -737,19 +751,23 @@ mp730_finish_scan (pixma_t * s) query_status (s); activate (s, 0); - if (! aborted && s->cfg->pid == IR1020_PID) - { - error = abort_session (s); - if (error < 0) - { - PDBG (pixma_dbg - (1, "WARNING:abort_session() failed %s\n", - pixma_strerror (error))); - query_status (s); - query_status (s); - activate (s, 0); - } - } + // MF57x0 devices don't require abort_session() after the last page + if (!aborted && + (s->param->source == PIXMA_SOURCE_ADF || + s->param->source == PIXMA_SOURCE_ADFDUP) && + has_paper (s) && + (s->cfg->pid == MF5730_PID || + s->cfg->pid == MF5750_PID || + s->cfg->pid == MF5770_PID || + s->cfg->pid == IR1020_PID)) + { + error = abort_session (s); + if (error < 0) + PDBG (pixma_dbg + (1, "WARNING:abort_session() failed %s\n", + pixma_strerror (error))); + } + mp->buf = mp->lbuf = mp->imgbuf = NULL; mp->state = state_idle; /* fall through */ @@ -808,6 +826,8 @@ static const pixma_scan_ops_t pixma_mp730_ops = { } const pixma_config_t pixma_mp730_devices[] = { /* TODO: check area limits */ + DEVICE ("PIXUS MP5/SmartBase MPC190/imageCLASS MPC190","MP5", MP5_PID, 600, 636, 868, PIXMA_CAP_LINEART),/* color scan can do 600x1200 */ + DEVICE ("PIXUS MP10/SmartBase MPC200/imageCLASS MPC200","MP10", MP10_PID, 600, 636, 868, PIXMA_CAP_LINEART),/* color scan can do 600x1200 */ DEVICE ("PIXMA MP360", "MP360", MP360_PID, 1200, 636, 868, PIXMA_CAP_LINEART), DEVICE ("PIXMA MP370", "MP370", MP370_PID, 1200, 636, 868, PIXMA_CAP_LINEART), DEVICE ("PIXMA MP375R", "MP375R", MP375R_PID, 1200, 636, 868, PIXMA_CAP_LINEART), diff --git a/backend/pixma_mp750.c b/backend/pixma_mp750.c index 8d2d94c..c5ac335 100644 --- a/backend/pixma_mp750.c +++ b/backend/pixma_mp750.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2006-2007 Wittawat Yamwong This file is part of the SANE package. diff --git a/backend/pixma_mp810.c b/backend/pixma_mp810.c index 5f9043e..b03bebc 100644 --- a/backend/pixma_mp810.c +++ b/backend/pixma_mp810.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -1009,6 +1009,7 @@ static int query_status (pixma_t * s) return error; } +#if 0 static int send_time (pixma_t * s) { /* Why does a scanner need a time? */ @@ -1025,6 +1026,7 @@ static int send_time (pixma_t * s) PDBG(pixma_dbg (3, "Sending time: '%s'\n", (char *) data)); return pixma_exec (s, &mp->cb); } +#endif /* TODO: Simplify this function. Read the whole data packet in one shot. */ static int read_image_block (pixma_t * s, uint8_t * header, uint8_t * data) @@ -1157,7 +1159,10 @@ static int handle_interrupt (pixma_t * s, int timeout) { /* More than one event can be reported at the same time. */ if (buf[3] & 1) - send_time (s); /* FIXME: some scanners hang here */ + /* FIXME: This function makes trouble with a lot of scanners + send_time (s); + */ + PDBG (pixma_dbg (1, "WARNING:send_time() disabled!\n")); if (buf[9] & 2) query_status (s); diff --git a/backend/pixma_sane_options.c b/backend/pixma_sane_options.c index 890b3ff..2e4a054 100644 --- a/backend/pixma_sane_options.c +++ b/backend/pixma_sane_options.c @@ -7,6 +7,8 @@ static const SANE_Range constraint_threshold = { 0,100,1 }; static const SANE_Range constraint_threshold_curve = { 0,127,1 }; +static const SANE_Range constraint_adf_wait = + { 0,3600,1 }; static @@ -340,6 +342,21 @@ int build_option_descriptors(struct pixma_sane_t *ss) sod->constraint.range = &constraint_threshold_curve; OPT_IN_CTX[opt_threshold_curve].info = 0; + opt = &(OPT_IN_CTX[opt_adf_wait]); + sod = &opt->sod; + sod->type = SANE_TYPE_INT; + sod->title = SANE_I18N("ADF Waiting Time"); + sod->desc = SANE_I18N("When set, the scanner searches the waiting time in seconds for a new document inserted into the automatic document feeder."); + sod->name = "adf-wait"; + sod->unit = SANE_UNIT_NONE; + sod->size = 1 * sizeof(SANE_Word); + sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC|SANE_CAP_INACTIVE; + sod->constraint_type = SANE_CONSTRAINT_RANGE; + sod->constraint.range = &constraint_adf_wait; + OPT_IN_CTX[opt_adf_wait].info = 0; + opt->def.w = 0; + opt->val.w = 0; + return 0; } diff --git a/backend/pixma_sane_options.h b/backend/pixma_sane_options.h index ccc9e34..669a234 100644 --- a/backend/pixma_sane_options.h +++ b/backend/pixma_sane_options.h @@ -35,6 +35,7 @@ typedef enum { opt__group_5, opt_threshold, opt_threshold_curve, + opt_adf_wait, opt_last } option_t; diff --git a/backend/plustek.c b/backend/plustek.c index cd83c26..062df37 100644 --- a/backend/plustek.c +++ b/backend/plustek.c @@ -416,21 +416,21 @@ sig_chldhandler( int signo ) /** signal handler to kill the child process */ -static RETSIGTYPE +static void reader_process_sigterm_handler( int signo ) { DBG( _DBG_PROC, "(SIG) reader_process: terminated by signal %d\n", signo ); _exit( SANE_STATUS_GOOD ); } -static RETSIGTYPE +static void usb_reader_process_sigterm_handler( int signo ) { DBG( _DBG_PROC, "(SIG) reader_process: terminated by signal %d\n", signo ); cancelRead = SANE_TRUE; } -static RETSIGTYPE +static void sigalarm_handler( int signo ) { _VAR_NOT_USED( signo ); @@ -572,7 +572,7 @@ do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe ) DBG( _DBG_PROC,"do_cancel\n" ); scanner->scanning = SANE_FALSE; - if( scanner->reader_pid != -1 ) { + if( sanei_thread_is_valid (scanner->reader_pid) ) { DBG( _DBG_PROC, ">>>>>>>> killing reader_process <<<<<<<<\n" ); @@ -2629,7 +2629,7 @@ sane_start( SANE_Handle handle ) cancelRead = SANE_FALSE; - if( s->reader_pid == -1 ) { + if( !sanei_thread_is_valid (s->reader_pid) ) { DBG( _DBG_ERROR, "ERROR: could not start reader task\n" ); s->scanning = SANE_FALSE; usbDev_close( dev ); diff --git a/backend/plustek_pp.c b/backend/plustek_pp.c index bf4c0d0..f48c3dc 100644 --- a/backend/plustek_pp.c +++ b/backend/plustek_pp.c @@ -348,13 +348,13 @@ static void sig_chldhandler( int signo ) /** signal handler to kill the child process */ -static RETSIGTYPE reader_process_sigterm_handler( int signo ) +static void reader_process_sigterm_handler( int signo ) { DBG( _DBG_PROC, "reader_process: terminated by signal %d\n", signo ); _exit( SANE_STATUS_GOOD ); } -static RETSIGTYPE sigalarm_handler( int signo ) +static void sigalarm_handler( int signo ) { _VAR_NOT_USED( signo ); DBG( _DBG_PROC, "ALARM!!!\n" ); @@ -471,7 +471,7 @@ static SANE_Status do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe ) scanner->scanning = SANE_FALSE; - if( scanner->reader_pid != -1 ) { + if( sanei_thread_is_valid( scanner->reader_pid )) { DBG( _DBG_PROC, ">>>>>>>> killing reader_process <<<<<<<<\n" ); @@ -2014,7 +2014,7 @@ SANE_Status sane_start( SANE_Handle handle ) s->w_pipe = fds[1]; s->reader_pid = sanei_thread_begin( reader_process, s ); - if( s->reader_pid == -1 ) { + if(!sanei_thread_is_valid( s->reader_pid )) { DBG( _DBG_ERROR, "ERROR: could not create child process\n" ); s->scanning = SANE_FALSE; s->hw->close( s->hw ); diff --git a/backend/pnm.c b/backend/pnm.c index b8d3192..ff4e2f2 100644 --- a/backend/pnm.c +++ b/backend/pnm.c @@ -649,7 +649,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, v = 75; DBG (2, "sane_control_option: handle=%p, opt=%d, act=%d, val=%p, info=%p\n", - handle, option, action, value, info); + handle, option, action, value, (void *) info); if (handle != MAGIC || !is_open) { diff --git a/backend/rts8891.c b/backend/rts8891.c index bdb4011..0eaff7b 100644 --- a/backend/rts8891.c +++ b/backend/rts8891.c @@ -617,7 +617,7 @@ set_automatic_value (Rts8891_Session * s, int option, SANE_Int * myinfo) { SANE_Status status = SANE_STATUS_GOOD; SANE_Int i, min; - SANE_Word *dpi_list; + const SANE_Word *dpi_list; switch (option) { @@ -639,7 +639,7 @@ set_automatic_value (Rts8891_Session * s, int option, SANE_Int * myinfo) break; case OPT_RESOLUTION: /* we set up to the lowest available dpi value */ - dpi_list = (SANE_Word *) s->opt[OPT_RESOLUTION].constraint.word_list; + dpi_list = s->opt[OPT_RESOLUTION].constraint.word_list; min = 65536; for (i = 1; i < dpi_list[0]; i++) { @@ -2233,11 +2233,11 @@ sane_close (SANE_Handle handle) if (session->dev->model->gamma != session->val[OPT_GAMMA_VECTOR_B].wa) free (session->val[OPT_GAMMA_VECTOR_B].wa); free (session->val[OPT_MODE].s); - free (session->opt[OPT_RESOLUTION].constraint.word_list); + free ((void *) session->opt[OPT_RESOLUTION].constraint.word_list); for (i = OPT_BUTTON_1; i <= OPT_BUTTON_11; i++) { - free (session->opt[i].name); - free (session->opt[i].title); + free ((void *) session->opt[i].name); + free ((void *) session->opt[i].title); } free (session); @@ -7702,7 +7702,7 @@ park_head (struct Rts8891_Device *dev, SANE_Bool wait) sanei_rts88xx_read_reg (dev->devnum, CONTROLER_REG, ®); if (reg != 0x20) { - DBG (DBG_warn, "park_head: unexpected controler value 0x%02x\n", reg); + DBG (DBG_warn, "park_head: unexpected controller value 0x%02x\n", reg); } /* head parking */ diff --git a/backend/rts88xx_lib.c b/backend/rts88xx_lib.c index bbbc83a..8e921f2 100644 --- a/backend/rts88xx_lib.c +++ b/backend/rts88xx_lib.c @@ -686,7 +686,7 @@ sanei_rts88xx_setup_nvram (SANE_Int devnum, SANE_Int length, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "sanei_rts88xx_setup_nvram : controler register write failed\n"); + "sanei_rts88xx_setup_nvram : controller register write failed\n"); return status; } reg = 1; @@ -694,7 +694,7 @@ sanei_rts88xx_setup_nvram (SANE_Int devnum, SANE_Int length, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "sanei_rts88xx_setup_nvram : controler register write failed\n"); + "sanei_rts88xx_setup_nvram : controller register write failed\n"); return status; } return status; diff --git a/backend/sharp.c b/backend/sharp.c index 1225a57..69f5000 100644 --- a/backend/sharp.c +++ b/backend/sharp.c @@ -370,7 +370,7 @@ sense_handler(int __sane_unused__ fd, u_char *sense_buffer, void *s) DBG(10, "error: invalid field in parameter list\n"); return SANE_STATUS_IO_ERROR; case 0x29: - DBG(10, "note: reset occured\n"); + DBG(10, "note: reset occurred\n"); return SANE_STATUS_GOOD; case 0x2a: DBG(10, "note: mode parameter change\n"); @@ -495,7 +495,7 @@ sense_handler(int __sane_unused__ fd, u_char *sense_buffer, void *s) switch (add_sense_code) { case 0x29: - DBG(5, "unit attention: reset occured\n"); + DBG(5, "unit attention: reset occurred\n"); return SANE_STATUS_GOOD; case 0x2a: DBG(5, "unit attention: parameter changed by " @@ -3299,7 +3299,7 @@ send_threshold_data(SHARP_Scanner *s) SANE_Status sane_start (SANE_Handle handle) { - char *mode, *halftone, *paper, *gamma, *edge, *lightcolor, *adf_fsu; + char *mode, *halftone, *gamma, *edge, *lightcolor, *adf_fsu; SHARP_Scanner *s = handle; SANE_Status status; size_t buf_size; @@ -3436,7 +3436,6 @@ sane_start (SANE_Handle handle) mode = s->val[OPT_MODE].s; halftone = s->val[OPT_HALFTONE].s; - paper = s->val[OPT_PAPER].s; gamma = s->val[OPT_GAMMA].s; edge = s->val[OPT_EDGE_EMPHASIS].s; lightcolor = s->val[OPT_LIGHTCOLOR].s; diff --git a/backend/sm3600.c b/backend/sm3600.c index dd1f31f..908e8be 100644 --- a/backend/sm3600.c +++ b/backend/sm3600.c @@ -73,7 +73,7 @@ Start: 2.4.2001 #include "../include/sane/saneopts.h" #include "../include/sane/sanei_usb.h" -#undef HAVE_LIBUSB +#undef HAVE_LIBUSB_LEGACY /* prevent inclusion of scantool.h */ #define SCANTOOL_H @@ -431,13 +431,11 @@ sane_exit (void) SANE_Status sane_get_devices (const SANE_Device *** device_list, - SANE_Bool local_only) + SANE_Bool __sane_unused__ local_only) { TDevice *dev; int i; - local_only = TRUE; /* Avoid compile warning */ - if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); @@ -458,7 +456,6 @@ sane_open (SANE_String_Const devicename, SANE_Handle *handle) { TDevice *pdev; TInstance *this; - SANE_Status rc; DBG(DEBUG_VERBOSE,"opening %s\n",devicename); if (devicename[0]) /* selected */ { @@ -488,8 +485,6 @@ DBG(DEBUG_VERBOSE,"%s<>%s\n",devicename, pdev->sane.name); if (sanei_usb_open (devicename, &this->hScanner) != SANE_STATUS_GOOD) return SetError (this, SANE_STATUS_IO_ERROR, "cannot open scanner device"); - rc = SANE_STATUS_GOOD; - this->quality=fast; return InitOptions(this); } diff --git a/backend/sm3840.c b/backend/sm3840.c old mode 100755 new mode 100644 diff --git a/backend/sm3840.h b/backend/sm3840.h old mode 100755 new mode 100644 diff --git a/backend/sm3840_lib.c b/backend/sm3840_lib.c old mode 100755 new mode 100644 index 485003c..163b356 --- a/backend/sm3840_lib.c +++ b/backend/sm3840_lib.c @@ -191,12 +191,12 @@ find_device (unsigned int idVendor, unsigned int idProduct) static void idle_ab (p_usb_dev_handle udev) { - int len, i; + int i; unsigned char buff[8] = { 0x64, 0x65, 0x16, 0x17, 0x64, 0x65, 0x44, 0x45 }; for (i = 0; i < 8; i++) { - len = usb_control_msg (udev, 0x40, 0x0c, 0x0090, 0x0000, buff + i, - 0x0001, wr_timeout); + usb_control_msg (udev, 0x40, 0x0c, 0x0090, 0x0000, buff + i, + 0x0001, wr_timeout); } } @@ -208,7 +208,7 @@ write_regs (p_usb_dev_handle udev, int regs, unsigned char reg1, { unsigned char buff[512]; va_list marker; - int len, i; + int i; va_start (marker, val1); buff[0] = reg1; @@ -220,8 +220,8 @@ write_regs (p_usb_dev_handle udev, int regs, unsigned char reg1, } va_end (marker); - len = usb_control_msg (udev, 0x40, 0x04, 0x00b0, 0x0000, buff, - regs * 2, wr_timeout); + usb_control_msg (udev, 0x40, 0x04, 0x00b0, 0x0000, buff, + regs * 2, wr_timeout); } static int @@ -297,7 +297,6 @@ record_line (int reset, unsigned char **save_dpi1200_remap, unsigned char **save_color_remap) { - int len; unsigned char *scan_line, *dpi1200_remap; unsigned char *color_remap; int i; @@ -374,7 +373,7 @@ record_line (int reset, while (1) { /* We'll exit inside the loop... */ - len = usb_bulk_read (udev, 1, scan_line, linelen, rd_timeout); + usb_bulk_read (udev, 1, scan_line, linelen, rd_timeout); if (dpi == 1200) { ptrcur = dpi1200_remap + (linelen * (i % DPI1200SHUFFLE)); @@ -886,7 +885,6 @@ download_lut8 (p_usb_dev_handle udev, int dpi, int incolor) 4.40306800664567E-31 }; unsigned char *lut; - int len; DBG (2, "+download_lut8\n"); switch (dpi) @@ -904,7 +902,7 @@ download_lut8 (p_usb_dev_handle udev, int dpi, int incolor) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x20, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x2f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, 0x1000, 0x00); - len = usb_bulk_write (udev, 2, lut, 4096, wr_timeout); + usb_bulk_write (udev, 2, lut, 4096, wr_timeout); } else { @@ -912,15 +910,15 @@ download_lut8 (p_usb_dev_handle udev, int dpi, int incolor) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x10, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x1f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, 0x1000, 0x00); - len = usb_bulk_write (udev, 2, lut, 4096, wr_timeout); + usb_bulk_write (udev, 2, lut, 4096, wr_timeout); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x20, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x2f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, 0x1000, 0x00); - len = usb_bulk_write (udev, 2, lut, 4096, wr_timeout); + usb_bulk_write (udev, 2, lut, 4096, wr_timeout); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x30, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x3f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, 0x1000, 0x00); - len = usb_bulk_write (udev, 2, lut, 4096, wr_timeout); + usb_bulk_write (udev, 2, lut, 4096, wr_timeout); } break; @@ -936,7 +934,7 @@ download_lut8 (p_usb_dev_handle udev, int dpi, int incolor) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x40, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0x5f, 0xb5, 0x06); write_vctl (udev, 0x0c, 0x0002, 0x2000, 0x00); - len = usb_bulk_write (udev, 2, lut, 8192, wr_timeout); + usb_bulk_write (udev, 2, lut, 8192, wr_timeout); } else { @@ -944,15 +942,15 @@ download_lut8 (p_usb_dev_handle udev, int dpi, int incolor) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x20, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0x3f, 0xb5, 0x06); write_vctl (udev, 0x0c, 0x0002, 0x2000, 0x00); - len = usb_bulk_write (udev, 2, lut, 8192, wr_timeout); + usb_bulk_write (udev, 2, lut, 8192, wr_timeout); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x40, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0x5f, 0xb5, 0x06); write_vctl (udev, 0x0c, 0x0002, 0x2000, 0x00); - len = usb_bulk_write (udev, 2, lut, 8192, wr_timeout); + usb_bulk_write (udev, 2, lut, 8192, wr_timeout); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x60, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0x7f, 0xb5, 0x06); write_vctl (udev, 0x0c, 0x0002, 0x2000, 0x00); - len = usb_bulk_write (udev, 2, lut, 8192, wr_timeout); + usb_bulk_write (udev, 2, lut, 8192, wr_timeout); } break; } diff --git a/backend/sm3840_lib.h b/backend/sm3840_lib.h old mode 100755 new mode 100644 diff --git a/backend/sm3840_scan.c b/backend/sm3840_scan.c old mode 100755 new mode 100644 index e9442a7..148e37b --- a/backend/sm3840_scan.c +++ b/backend/sm3840_scan.c @@ -158,7 +158,6 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) int scanlines = p->scanlines; int leftpix = p->leftpix; int scanpix = p->scanpix; - int len; unsigned char hello[2] = { 0x55, 0xaa }; unsigned char howdy[3]; unsigned short *whitebalance; @@ -182,11 +181,11 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) char fname[64]; char head[128]; - len = usb_set_configuration (udev, 1); - len = usb_claim_interface (udev, 0); - len = usb_clear_halt (udev, 1); - len = usb_clear_halt (udev, 2); - len = usb_clear_halt (udev, 3); + usb_set_configuration (udev, 1); + usb_claim_interface (udev, 0); + usb_clear_halt (udev, 1); + usb_clear_halt (udev, 2); + usb_clear_halt (udev, 3); #endif DBG (2, "params.gray = %d;\n", p->gray); DBG (2, "params.dpi = %d\n", p->dpi); @@ -255,12 +254,12 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) write_regs (udev, 1, 0xb1, 0x00); write_regs (udev, 1, 0xb2, 0x00); write_vctl (udev, 0x0c, 0x0002, 0x0002, 0x00); - len = usb_bulk_write (udev, 2, hello, 2, wr_timeout); + usb_bulk_write (udev, 2, hello, 2, wr_timeout); write_regs (udev, 1, 0xb0, 0x00); write_regs (udev, 1, 0xb1, 0x00); write_regs (udev, 1, 0xb2, 0x00); write_vctl (udev, 0x0c, 0x0003, 0x0003, 0x00); - len = usb_bulk_read (udev, 1, howdy, 3, rd_timeout); + usb_bulk_read (udev, 1, howdy, 3, rd_timeout); write_regs (udev, 4, 0x83, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0x97, 0x0a); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); @@ -318,9 +317,8 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x40, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x7f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); - len = - usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, - wr_timeout); + usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, + wr_timeout); set_lightmap_white (whitemap, dpi, 1); if (dpi == 1200) @@ -330,9 +328,8 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x80, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xbf, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); - len = - usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, - wr_timeout); + usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, + wr_timeout); set_lightmap_white (whitemap, dpi, 2); if (dpi == 1200) @@ -342,9 +339,8 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0xc0, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); - len = - usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, - wr_timeout); + usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, + wr_timeout); free (whitemap); @@ -391,11 +387,10 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); whitebalance = (unsigned short *) malloc (whitebalancesize); - len = usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); + usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); - len = - usb_bulk_read (udev, 1, (unsigned char *) whitebalance, whitebalancesize, - rd_timeout); + usb_bulk_read (udev, 1, (unsigned char *) whitebalance, whitebalancesize, + rd_timeout); write_regs (udev, 2, 0xbe, 0x00, 0x84, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); @@ -419,11 +414,10 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) 0xbf, 0x00, 0x90, 0x40, 0x91, 0x00, 0x83, 0x82); write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); - len = usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); + usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); - len = - usb_bulk_read (udev, 1, (unsigned char *) whitebalance, - whitebalancesize, rd_timeout); + usb_bulk_read (udev, 1, (unsigned char *) whitebalance, + whitebalancesize, rd_timeout); fix_endian_short (whitebalance, whitebalancesize/2); if (!donered) { @@ -485,11 +479,10 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) 0xbf, 0x00, 0x90, 0x40, 0x91, 0x00, 0x83, 0x82); write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); - len = usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); + usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); - len = - usb_bulk_read (udev, 1, (unsigned char *) whitebalance, - whitebalancesize, rd_timeout); + usb_bulk_read (udev, 1, (unsigned char *) whitebalance, + whitebalancesize, rd_timeout); fix_endian_short (whitebalance, whitebalancesize/2); if (!donered) { @@ -601,7 +594,7 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) 0x00, 0x90, 0x40, 0x91, 0x00, 0x83, 0x82); write_regs (udev, 1, 0xbe, 0x1d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); - len = usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); + usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); record_mem (udev, (unsigned char **) (void *)&whitescan, (5632 * 2 * 3 * (dpi == 1200 ? 2 : 1)) * 4); @@ -756,9 +749,8 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x40, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x7f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); - len = - usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, - wr_timeout); + usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, + wr_timeout); calc_lightmap (whitescan, lightmap, 1, dpi, gain, offset); if (dpi == 1200) @@ -772,9 +764,8 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) if (gray) for (i = 0; i < whitemapsize / 2; i++) lightmap[i] |= GRAYMASK; - len = - usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, - wr_timeout); + usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, + wr_timeout); calc_lightmap (whitescan, lightmap, 2, dpi, gain, offset); if (dpi == 1200) @@ -784,9 +775,8 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0xc0, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); - len = - usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, - wr_timeout); + usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, + wr_timeout); free (whitescan); free (lightmap); @@ -922,7 +912,7 @@ setup_scan (p_usb_dev_handle udev, SM3840_Params * p) else write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); - len = usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); + usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); #ifndef BACKENDNAME diff --git a/backend/snapscan-mutex.c b/backend/snapscan-mutex.c index 0321741..ad0538a 100644 --- a/backend/snapscan-mutex.c +++ b/backend/snapscan-mutex.c @@ -44,7 +44,7 @@ #include #define snapscan_mutex_t sem_id -static int snapscani_mutex_open(snapscan_mutex_t* a_sem, const char* dev UNUSEDARG) +static int snapscani_mutex_open(snapscan_mutex_t* a_sem, const char* dev __sane_unused__) { *a_sem = create_sem(1, "snapscan_mutex"); return 1; @@ -72,7 +72,7 @@ static void snapscani_mutex_unlock(snapscan_mutex_t* a_sem) #include #define snapscan_mutex_t pthread_mutex_t -static int snapscani_mutex_open(snapscan_mutex_t* sem_id, const char* dev UNUSEDARG) +static int snapscani_mutex_open(snapscan_mutex_t* sem_id, const char* dev __sane_unused__) { pthread_mutex_init(sem_id, NULL); return 1; diff --git a/backend/snapscan-sources.c b/backend/snapscan-sources.c index 63eadb2..dc78394 100644 --- a/backend/snapscan-sources.c +++ b/backend/snapscan-sources.c @@ -105,10 +105,6 @@ I hope this makes sense to you (and I got the right idea of the original author' intention). ***********************************************************************************/ -#ifndef __FUNCTION__ -#define __FUNCTION__ "(undef)" -#endif - static SANE_Status Source_init (Source *pself, SnapScan_Scanner *pss, SourceRemaining remaining, @@ -266,13 +262,13 @@ static SANE_Status FDSource_get (Source *pself, SANE_Byte *pbuf, SANE_Int *plen) } /* It's an IO error */ DBG (DL_MAJOR_ERROR, "%s: read failed: %s\n", - __FUNCTION__, strerror(errno)); + __func__, strerror(errno)); status = SANE_STATUS_IO_ERROR; } else if (bytes_read == 0) { /* EOF of current reading */ - DBG(DL_DATA_TRACE, "%s: EOF\n",__FUNCTION__); + DBG(DL_DATA_TRACE, "%s: EOF\n",__func__); break; } ps->bytes_remaining -= bytes_read; @@ -623,7 +619,7 @@ static SANE_Status Expander_init (Expander *pself, { DBG (DL_MAJOR_ERROR, "%s: couldn't allocate channel buffer.\n", - __FUNCTION__); + __func__); status = SANE_STATUS_NO_MEM; } else @@ -654,7 +650,7 @@ static SANE_Status create_Expander (SnapScan_Scanner *pss, { DBG (DL_MAJOR_ERROR, "%s: failed to allocate Expander.\n", - __FUNCTION__); + __func__); status = SANE_STATUS_NO_MEM; } else @@ -871,7 +867,7 @@ static SANE_Status Deinterlacer_init (Deinterlacer *pself, { DBG (DL_MAJOR_ERROR, "%s: couldn't allocate channel buffer.\n", - __FUNCTION__); + __func__); status = SANE_STATUS_NO_MEM; } else @@ -901,7 +897,7 @@ static SANE_Status create_Deinterlacer (SnapScan_Scanner *pss, { DBG (DL_MAJOR_ERROR, "%s: failed to allocate Deinterlacer.\n", - __FUNCTION__); + __func__); status = SANE_STATUS_NO_MEM; } else @@ -1106,7 +1102,7 @@ static SANE_Status RGBRouter_init (RGBRouter *pself, { DBG (DL_MAJOR_ERROR, "%s: failed to allocate circular buffer.\n", - __FUNCTION__); + __func__); status = SANE_STATUS_NO_MEM; } else @@ -1141,7 +1137,7 @@ static SANE_Status create_RGBRouter (SnapScan_Scanner *pss, if (*pps == NULL) { DBG (DL_MAJOR_ERROR, "%s: failed to allocate RGBRouter.\n", - __FUNCTION__); + __func__); status = SANE_STATUS_NO_MEM; } else @@ -1193,7 +1189,7 @@ static SANE_Status create_Inverter (SnapScan_Scanner *pss, if (*pps == NULL) { DBG (DL_MAJOR_ERROR, "%s: failed to allocate Inverter.\n", - __FUNCTION__); + __func__); status = SANE_STATUS_NO_MEM; } else @@ -1256,7 +1252,7 @@ static SANE_Status create_source_chain (SnapScan_Scanner *pss, break; default: DBG (DL_MAJOR_ERROR, "%s: bad mode value %d (internal error)\n", - __FUNCTION__, mode); + __func__, mode); status = SANE_STATUS_INVAL; break; } diff --git a/backend/snapscan.c b/backend/snapscan.c index 3c0fb81..c88537b 100644 --- a/backend/snapscan.c +++ b/backend/snapscan.c @@ -82,12 +82,6 @@ #define BUILD 53 #define BACKEND_NAME snapscan -#ifdef __GNUC__ -#define UNUSEDARG __attribute__ ((unused)) -#else -#define UNUSEDARG -#endif - #include "../include/sane/sanei_backend.h" #include "../include/sane/saneopts.h" @@ -1217,13 +1211,13 @@ static void reader (SnapScan_Scanner *pss) /** signal handler to kill the child process */ -static RETSIGTYPE usb_reader_process_sigterm_handler( int signo ) +static void usb_reader_process_sigterm_handler( int signo ) { DBG( DL_INFO, "(SIG) reader_process: terminated by signal %d\n", signo ); cancelRead = SANE_TRUE; } -static RETSIGTYPE sigalarm_handler( int signo UNUSEDARG) +static void sigalarm_handler( int signo __sane_unused__) { DBG( DL_INFO, "ALARM!!!\n" ); } @@ -1301,7 +1295,7 @@ static SANE_Status start_reader (SnapScan_Scanner *pss) cancelRead = SANE_FALSE; - if (pss->child == -1) + if (!sanei_thread_is_valid (pss->child)) { /* we'll have to read in blocking mode */ DBG (DL_MAJOR_ERROR, @@ -1815,7 +1809,7 @@ SANE_Status sane_read (SANE_Handle h, if (pss->psrc == NULL || pss->psrc->remaining(pss->psrc) == 0) { - if (pss->child != -1) + if (sanei_thread_is_valid (pss->child)) { sanei_thread_waitpid (pss->child, 0); /* ensure no zombies */ pss->child = -1; @@ -1875,7 +1869,7 @@ void sane_cancel (SANE_Handle h) /* signal a cancellation has occurred */ pss->state = ST_CANCEL_INIT; /* signal the reader, if any */ - if (pss->child != -1) + if (sanei_thread_is_valid (pss->child)) { DBG( DL_INFO, ">>>>>>>> killing reader_process <<<<<<<<\n" ); @@ -1941,7 +1935,7 @@ SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool m) if (m) { - if (pss->child == -1) + if (!sanei_thread_is_valid (pss->child)) { DBG (DL_MINOR_INFO, "%s: no reader child; must use blocking mode.\n", @@ -1971,7 +1965,7 @@ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fd) if (pss->state != ST_SCAN_INIT) return SANE_STATUS_INVAL; - if (pss->child == -1) + if (!sanei_thread_is_valid (pss->child)) { DBG (DL_MINOR_INFO, "%s: no reader child; cannot provide select file descriptor.\n", diff --git a/backend/sp15c.c b/backend/sp15c.c index 3937a30..0cabed8 100644 --- a/backend/sp15c.c +++ b/backend/sp15c.c @@ -1762,7 +1762,7 @@ do_cancel (struct sp15c *scanner) do_eof (scanner); /* close pipe and reposition scanner */ - if (scanner->reader_pid != -1) + if (sanei_thread_is_valid (scanner->reader_pid)) { int exit_status; DBG (10, "do_cancel: kill reader_process\n"); diff --git a/backend/stv680.conf.in b/backend/stv680.conf.in old mode 100755 new mode 100644 diff --git a/backend/stv680.h b/backend/stv680.h old mode 100755 new mode 100644 diff --git a/backend/tamarack.c b/backend/tamarack.c index e7073af..6fc259f 100644 --- a/backend/tamarack.c +++ b/backend/tamarack.c @@ -470,7 +470,7 @@ do_cancel (Tamarack_Scanner *s) do_eof (s); - if (s->reader_pid != -1) + if (sanei_thread_is_valid (s->reader_pid)) { int exit_status; @@ -1442,7 +1442,7 @@ sane_cancel (SANE_Handle handle) { Tamarack_Scanner *s = handle; - if (s->reader_pid != -1) + if (sanei_thread_is_valid (s->reader_pid)) sanei_thread_kill (s->reader_pid); s->scanning = SANE_FALSE; } diff --git a/backend/test.c b/backend/test.c index d5b7365..2ca5b3b 100644 --- a/backend/test.c +++ b/backend/test.c @@ -1355,7 +1355,7 @@ finish_pass (Test_Device * test_device) DBG (2, "finish_pass: pipe closed\n"); test_device->pipe = -1; } - if (test_device->reader_pid != -1) + if (sanei_thread_is_valid (test_device->reader_pid)) { int status; SANE_Pid pid; @@ -1364,7 +1364,7 @@ finish_pass (Test_Device * test_device) (long) test_device->reader_pid); sanei_thread_kill (test_device->reader_pid); pid = sanei_thread_waitpid (test_device->reader_pid, &status); - if (pid == -1) + if (!sanei_thread_is_valid (pid)) { DBG (1, "finish_pass: sanei_thread_waitpid failed, already terminated? (%s)\n", @@ -2568,7 +2568,7 @@ sane_start (SANE_Handle handle) test_device->reader_pid = sanei_thread_begin (reader_task, (void *) test_device); - if (test_device->reader_pid == -1) + if (!sanei_thread_is_valid (test_device->reader_pid)) { DBG (1, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)); diff --git a/backend/u12-hw.c b/backend/u12-hw.c index 89f37be..e21c78a 100644 --- a/backend/u12-hw.c +++ b/backend/u12-hw.c @@ -338,7 +338,6 @@ static void u12hw_SetGeneralRegister( U12_Device *dev ) static void u12hw_SetupPreviewCondition( U12_Device *dev ) { int i, c; - u_long channel; SANE_Byte rb[100]; DBG( _DBG_INFO, "u12_SetupPreviewCondition()\n" ); @@ -389,7 +388,6 @@ static void u12hw_SetupPreviewCondition( U12_Device *dev ) else dev->scan.bFifoSelect = REG_GFIFOOFFSET; - channel = _BLUE_FULLSIZE << 16; dev->regs.RD_BufFullSize = _SIZE_BLUEFIFO; dev->regs.RD_LineControl = _LOBYTE(dev->shade.wExposure); diff --git a/backend/u12.c b/backend/u12.c index 8401a9f..083d9f3 100644 --- a/backend/u12.c +++ b/backend/u12.c @@ -278,19 +278,19 @@ static void sig_chldhandler( int signo ) /** signal handler to kill the child process */ -static RETSIGTYPE reader_process_sigterm_handler( int signo ) +static void reader_process_sigterm_handler( int signo ) { DBG( _DBG_PROC, "(SIG) reader_process: terminated by signal %d\n", signo ); _exit( SANE_STATUS_GOOD ); } -static RETSIGTYPE usb_reader_process_sigterm_handler( int signo ) +static void usb_reader_process_sigterm_handler( int signo ) { DBG( _DBG_PROC, "(SIG) reader_process: terminated by signal %d\n", signo ); cancelRead = SANE_TRUE; } -static RETSIGTYPE sigalarm_handler( int signo ) +static void sigalarm_handler( int signo ) { _VAR_NOT_USED( signo ); DBG( _DBG_PROC, "ALARM!!!\n" ); @@ -391,7 +391,7 @@ static SANE_Status do_cancel( U12_Scanner *scanner, SANE_Bool closepipe ) scanner->scanning = SANE_FALSE; - if( scanner->reader_pid != -1 ) { + if( sanei_thread_is_valid (scanner->reader_pid) ) { DBG( _DBG_PROC, ">>>>>>>> killing reader_process <<<<<<<<\n" ); @@ -1731,7 +1731,7 @@ SANE_Status sane_start( SANE_Handle handle ) cancelRead = SANE_FALSE; - if( s->reader_pid == -1 ) { + if( !sanei_thread_is_valid (s->reader_pid) ) { DBG( _DBG_ERROR, "ERROR: could not start reader task\n" ); s->scanning = SANE_FALSE; u12if_close( dev ); diff --git a/backend/umax.c b/backend/umax.c index 0d8ddba..22fa2d3 100644 --- a/backend/umax.c +++ b/backend/umax.c @@ -399,7 +399,7 @@ static void umax_print_inquiry(Umax_Device *dev) DBG_inq_nz(" - relative address\n", get_inquiry_scsi_reladr(inquiry_block)); DBG_inq_nz(" - wide bus 32 bit\n", get_inquiry_scsi_wbus32(inquiry_block)); DBG_inq_nz(" - wide bus 16 bit\n", get_inquiry_scsi_wbus16(inquiry_block)); - DBG_inq_nz(" - syncronous neg.\n", get_inquiry_scsi_sync(inquiry_block)); + DBG_inq_nz(" - synchronous neg.\n", get_inquiry_scsi_sync(inquiry_block)); DBG_inq_nz(" - linked commands\n", get_inquiry_scsi_linked(inquiry_block)); DBG_inq_nz(" - (reserved)\n", get_inquiry_scsi_R(inquiry_block)); DBG_inq_nz(" - command queueing\n", get_inquiry_scsi_cmdqueue(inquiry_block)); @@ -526,7 +526,7 @@ static void umax_print_inquiry(Umax_Device *dev) DBG_inq_nz(" + ADF: no paper\n", get_inquiry_ADF_no_paper(inquiry_block)); DBG_inq_nz(" + ADF: cover open\n", get_inquiry_ADF_cover_open(inquiry_block)); DBG_inq_nz(" + ADF: paper jam\n", get_inquiry_ADF_paper_jam(inquiry_block)); - DBG_inq_nz(" - unknwon flag; 0x63 bit 3\n", get_inquiry_0x63_bit3(inquiry_block)); + DBG_inq_nz(" - unknown flag; 0x63 bit 3\n", get_inquiry_0x63_bit3(inquiry_block)); DBG_inq_nz(" - unknown lfag: 0x63 bit 4\n", get_inquiry_0x63_bit4(inquiry_block)); DBG_inq_nz(" - lens calib in doc pos\n", get_inquiry_lens_cal_in_doc_pos(inquiry_block)); DBG_inq_nz(" - manual focus\n", get_inquiry_manual_focus(inquiry_block)); @@ -4670,14 +4670,14 @@ static SANE_Status do_cancel(Umax_Scanner *scanner) scanner->scanning = SANE_FALSE; - if (scanner->reader_pid != -1) + if (sanei_thread_is_valid (scanner->reader_pid)) { DBG(DBG_sane_info,"killing reader_process\n"); sanei_thread_kill(scanner->reader_pid); pid = sanei_thread_waitpid(scanner->reader_pid, &status); - if (pid == -1) + if (!sanei_thread_is_valid (pid)) { DBG(DBG_sane_info, "do_cancel: sanei_thread_waitpid failed, already terminated ? (%s)\n", strerror(errno)); } @@ -4928,7 +4928,7 @@ static SANE_Status attach_scanner(const char *devicename, Umax_Device **devp, in /* ------------------------------------------------------------ READER PROCESS SIGTERM HANDLER ------------ */ -static RETSIGTYPE reader_process_sigterm_handler(int signal) +static void reader_process_sigterm_handler(int signal) { DBG(DBG_sane_info,"reader_process: terminated by signal %d\n", signal); @@ -7624,7 +7624,7 @@ SANE_Status sane_start(SANE_Handle handle) /* of the x-origin defined by the scanner`s inquiry */ if (scanner->device->dor != 0) /* dor mode active */ { - DBG(DBG_info,"substracting DOR x-origin-offset from upper left x\n"); + DBG(DBG_info,"subtracting DOR x-origin-offset from upper left x\n"); scanner->device->upper_left_x -= scanner->device->inquiry_dor_x_off * scanner->device->x_coordinate_base; /* correct DOR x-origin */ if (scanner->device->upper_left_x < 0) /* rounding errors may create a negative value */ @@ -7996,7 +7996,7 @@ SANE_Status sane_start(SANE_Handle handle) /* start reader_process, deponds on OS if fork() or threads are used */ scanner->reader_pid = sanei_thread_begin(reader_process, (void *) scanner); - if (scanner->reader_pid == -1) + if (!sanei_thread_is_valid (scanner->reader_pid)) { DBG(DBG_error, "ERROR: sanei_thread_begin failed (%s)\n", strerror(errno)); scanner->scanning = SANE_FALSE; diff --git a/backend/umax1220u.c b/backend/umax1220u.c index e04d908..79b8c92 100644 --- a/backend/umax1220u.c +++ b/backend/umax1220u.c @@ -742,7 +742,6 @@ void sane_close (SANE_Handle handle) { Umax_Scanner *prev, *scanner; - SANE_Status res; DBG (3, "sane_close\n"); @@ -775,7 +774,7 @@ sane_close (SANE_Handle handle) else first_handle = scanner->next; - res = UMAX_close_device (&scanner->scan); + UMAX_close_device (&scanner->scan); free (scanner); } diff --git a/backend/umax_pp.c b/backend/umax_pp.c index 90cd486..0f7ce4e 100644 --- a/backend/umax_pp.c +++ b/backend/umax_pp.c @@ -388,7 +388,7 @@ umax_pp_try_ports (SANEI_Config * config, char **ports) ports[i]); else DBG (3, - "umax_pp_try_ports: attach to port `%s' successfull\n", + "umax_pp_try_ports: attach to port `%s' successful\n", ports[i]); } free (ports[i]); @@ -1001,9 +1001,9 @@ sane_exit (void) for (i = 0; i < num_devices; i++) { free (devlist[i].port); - free (devlist[i].sane.name); - free (devlist[i].sane.model); - free (devlist[i].sane.vendor); + free ((void *) devlist[i].sane.name); + free ((void *) devlist[i].sane.model); + free ((void *) devlist[i].sane.vendor); } if (devlist != NULL) diff --git a/backend/umax_pp.h b/backend/umax_pp.h index 27ee95e..dbedab8 100644 --- a/backend/umax_pp.h +++ b/backend/umax_pp.h @@ -193,15 +193,8 @@ enum Umax_PP_Configure_Option NUM_CFG_OPTIONS }; -#if (!defined __GNUC__ || __GNUC__ < 2 || \ - __GNUC_MINOR__ < (defined __cplusplus ? 6 : 4)) - -#define __PRETTY_FUNCTION__ "umax_pp" - -#endif - #define DEBUG() DBG(4, "%s(v%d.%d.%d-%s): line %d: debug exception\n", \ - __PRETTY_FUNCTION__, SANE_CURRENT_MAJOR, V_MINOR, \ + __func__, SANE_CURRENT_MAJOR, V_MINOR, \ UMAX_PP_BUILD, UMAX_PP_STATE, __LINE__) #endif /* umax_pp_h */ diff --git a/backend/umax_pp_low.c b/backend/umax_pp_low.c index c5f58a7..1e38aba 100644 --- a/backend/umax_pp_low.c +++ b/backend/umax_pp_low.c @@ -65,6 +65,7 @@ #include #endif #include "../include/sane/sanei_debug.h" +#include "../include/sane/sanei_backend.h" #include #ifdef HAVE_DEV_PPBUS_PPI_H @@ -406,75 +407,51 @@ sanei_outsl (unsigned int port, const void *addr, unsigned long count) #ifndef ENABLE_PARPORT_DIRECTIO #define SANE_INB 0 static int -sanei_ioperm (int start, int length, int enable) +sanei_ioperm (__sane_unused__ int start, __sane_unused__ int length, + __sane_unused__ int enable) { - /* make compilers happy */ - enable = start + length; - /* returns failure */ return -1; } static unsigned char -sanei_inb (unsigned int port) +sanei_inb (__sane_unused__ unsigned int port) { - /* makes compilers happy */ - port = 0; return 255; } static void -sanei_outb (unsigned int port, unsigned char value) +sanei_outb (__sane_unused__ unsigned int port, + __sane_unused__ unsigned char value) { - /* makes compilers happy */ - port = 0; - value = 0; } static void -sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) +sanei_insb (__sane_unused__ unsigned int port, + __sane_unused__ unsigned char *addr, + __sane_unused__ unsigned long count) { - /* makes compilers happy */ - if (addr) - { - port = 0; - count = 0; - } } static void -sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) +sanei_insl (__sane_unused__ unsigned int port, + __sane_unused__ unsigned char *addr, + __sane_unused__ unsigned long count) { - /* makes compilers happy */ - if (addr) - { - port = 0; - count = 0; - } } static void -sanei_outsb (unsigned int port, const unsigned char *addr, - unsigned long count) +sanei_outsb (__sane_unused__ unsigned int port, + __sane_unused__ const unsigned char *addr, + __sane_unused__ unsigned long count) { - /* makes compilers happy */ - if (addr) - { - port = 0; - count = 0; - } } static void -sanei_outsl (unsigned int port, const unsigned char *addr, - unsigned long count) +sanei_outsl (__sane_unused__ unsigned int port, + __sane_unused__ const unsigned char *addr, + __sane_unused__ unsigned long count) { - /* makes compilers happy */ - if (addr) - { - port = 0; - count = 0; - } } #endif /* ENABLE_PARPORT_DIRECTIO is not defined */ @@ -862,7 +839,7 @@ sanei_parport_find_device (void) i = 0; while (devices[i] != NULL) { - DBG (16, "Controling %s: ", devices[i]); + DBG (16, "Controlling %s: ", devices[i]); file = open (devices[i], O_RDWR); if (file < 0) { @@ -950,7 +927,7 @@ int sanei_umax_pp_initPort (int port, char *name) { int fd, ectr; - int found = 0, ecp = 1; + int found = 0; #if ((defined HAVE_IOPERM)||(defined HAVE_MACHINE_CPUFUNC_H)||(defined HAVE_LINUX_PPDEV_H)) int mode, modes, rc; #endif @@ -1095,7 +1072,7 @@ sanei_umax_pp_initPort (int port, char *name) if (rc) { DBG (16, - "umax_pp: ppdev couldn't negociate mode IEEE1284_MODE_EPP for '%s' (ignored)\n", + "umax_pp: ppdev couldn't negotiate mode IEEE1284_MODE_EPP for '%s' (ignored)\n", name); } if (ioctl (fd, PPSETMODE, &mode)) @@ -1121,7 +1098,7 @@ sanei_umax_pp_initPort (int port, char *name) if (rc) { DBG (16, - "umax_pp: ppdev couldn't negociate mode IEEE1284_MODE_ECP for '%s' (ignored)\n", + "umax_pp: ppdev couldn't negotiate mode IEEE1284_MODE_ECP for '%s' (ignored)\n", name); } if (ioctl (fd, PPSETMODE, &mode)) @@ -1234,7 +1211,6 @@ sanei_umax_pp_initPort (int port, char *name) { DBG (1, "iopl could not raise IO permission to level 3\n"); DBG (1, "*NO* ECP support\n"); - ecp = 0; } else @@ -1247,8 +1223,6 @@ sanei_umax_pp_initPort (int port, char *name) } } -#else - ecp = 0; #endif @@ -2126,8 +2100,6 @@ sendCommand (int cmd) int tmp; int val; int i; - int gbufferRead[256]; /* read buffer for command 0x10 */ - if (g674 != 0) { @@ -2216,7 +2188,7 @@ sendCommand (int cmd) tmp = (tmp & 0x1E) | 0x1; Outb (CONTROL, tmp); Outb (CONTROL, tmp); - gbufferRead[i] = Inb (STATUS); + Inb (STATUS); tmp = tmp & 0x1E; Outb (CONTROL, tmp); Outb (CONTROL, tmp); @@ -2721,7 +2693,7 @@ init002 (int arg) static int ECPconnect (void) { - int ret, control, data; + int ret, control; /* these 3 lines set to 'inital mode' */ byteMode (); /*Outb (ECR, 0x20); */ @@ -2735,7 +2707,7 @@ ECPconnect (void) gData = Inb (DATA); gControl = Inb (CONTROL); - data = Inb (DATA); + Inb (DATA); control = Inb (CONTROL); Outb (CONTROL, control & 0x1F); control = Inb (CONTROL); @@ -3224,7 +3196,6 @@ static void ECPSetBuffer (int size) { static int last = 0; - unsigned char breg; /* routine XX */ compatMode (); @@ -3244,7 +3215,7 @@ ECPSetBuffer (int size) __FILE__, __LINE__); return; } - breg = Inb (ECR); + Inb (ECR); Outb (DATA, 0x0E); if (waitFifoEmpty () == 0) @@ -3253,7 +3224,7 @@ ECPSetBuffer (int size) __FILE__, __LINE__); return; } - breg = Inb (ECR); + Inb (ECR); Outb (ECPDATA, 0x0B); /* R0E=0x0B */ if (waitFifoEmpty () == 0) @@ -3262,7 +3233,7 @@ ECPSetBuffer (int size) __FILE__, __LINE__); return; } - breg = Inb (ECR); + Inb (ECR); Outb (DATA, 0x0F); /* R0F=size MSB */ if (waitFifoEmpty () == 0) @@ -3271,7 +3242,7 @@ ECPSetBuffer (int size) __FILE__, __LINE__); return; } - breg = Inb (ECR); + Inb (ECR); Outb (ECPDATA, size / 256); if (waitFifoEmpty () == 0) @@ -3280,7 +3251,7 @@ ECPSetBuffer (int size) __FILE__, __LINE__); return; } - breg = Inb (ECR); + Inb (ECR); Outb (DATA, 0x0B); /* R0B=size LSB */ if (waitFifoEmpty () == 0) @@ -3289,7 +3260,7 @@ ECPSetBuffer (int size) __FILE__, __LINE__); return; } - breg = Inb (ECR); + Inb (ECR); Outb (ECPDATA, size % 256); if (waitFifoEmpty () == 0) @@ -3298,7 +3269,7 @@ ECPSetBuffer (int size) __FILE__, __LINE__); return; } - breg = Inb (ECR); + Inb (ECR); DBG (16, "ECPSetBuffer(%d) passed ...\n", size); } @@ -3307,14 +3278,14 @@ ECPSetBuffer (int size) static int ECPbufferRead (int size, unsigned char *dest) { - int breg, n, idx, remain; + int n, idx, remain; idx = 0; n = size / 16; remain = size - 16 * n; /* block transfer */ - breg = Inb (ECR); /* 0x15,0x75 expected: fifo empty */ + Inb (ECR); /* 0x15,0x75 expected: fifo empty */ byteMode (); /*Outb (ECR, 0x20); byte mode */ Outb (CONTROL, 0x04); @@ -3326,7 +3297,7 @@ ECPbufferRead (int size, unsigned char *dest) __FILE__, __LINE__); return idx; } - breg = Inb (ECR); + Inb (ECR); Outb (DATA, 0x80); if (waitFifoEmpty () == 0) @@ -3335,7 +3306,7 @@ ECPbufferRead (int size, unsigned char *dest) __FILE__, __LINE__); return idx; } - breg = Inb (ECR); /* 0x75 expected */ + Inb (ECR); /* 0x75 expected */ byteMode (); /*Outb (ECR, 0x20); byte mode */ Outb (CONTROL, 0x20); /* data reverse */ @@ -4066,13 +4037,12 @@ static int EPPconnect (void) { int control; - int data; /* initial values, don't hardcode */ Outb (DATA, 0x04); Outb (CONTROL, 0x0C); - data = Inb (DATA); + Inb (DATA); control = Inb (CONTROL); Outb (CONTROL, control & 0x1F); control = Inb (CONTROL); @@ -8968,7 +8938,7 @@ cmdGetBuffer610p (int cmd, int len, unsigned char *buffer) static int cmdGetBuffer (int cmd, int len, unsigned char *buffer) { - int reg, tmp, i; + int reg, tmp; int word[5], read; int needed; @@ -8995,7 +8965,6 @@ cmdGetBuffer (int cmd, int len, unsigned char *buffer) REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); - i = 0; reg = registerRead (0x19) & 0xF8; /* wait if busy */ @@ -9108,7 +9077,7 @@ cmdGetBuffer (int cmd, int len, unsigned char *buffer) static int cmdGetBuffer32 (int cmd, int len, unsigned char *buffer) { - int reg, tmp, i; + int reg, tmp; int word[5], read; /* compute word */ @@ -9138,7 +9107,6 @@ cmdGetBuffer32 (int cmd, int len, unsigned char *buffer) REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); - i = 0; reg = registerRead (0x19) & 0xF8; /* wait if busy */ @@ -9255,7 +9223,7 @@ cmdGetBlockBuffer (int cmd, int len, int window, unsigned char *buffer) struct timeval td, tf; float elapsed; #endif - int reg, i; + int reg; int word[5], read; /* compute word */ @@ -9292,8 +9260,6 @@ cmdGetBlockBuffer (int cmd, int len, int window, unsigned char *buffer) REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); - i = 0; - /* init counter */ read = 0; @@ -10975,7 +10941,6 @@ sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi, int *rtw, int *rth) { unsigned char *buffer; - int *dest = NULL; int rc = 0; int calibration[3 * 5100 + 768 + 2 + 1]; int xdpi, ydpi, h; @@ -11107,8 +11072,6 @@ sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi, } DBG (16, "inquire() passed ... (%s:%d)\n", __FILE__, __LINE__); - dest = (int *) malloc (65536 * sizeof (int)); - rc = loadDefaultTables (); if (rc == 0) { @@ -11936,7 +11899,6 @@ offsetCalibration1220p (int color, int *offRed, int *offGreen, int *offBlue) int i, val; int commit[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, -1 }; int opsc04[9] = { 0x06, 0xF4, 0xFF, 0x81, 0x1B, 0x00, 0x00, 0x00, -1 }; - int opsc10[9] = { 0x06, 0xF4, 0xFF, 0x81, 0x1B, 0x00, 0x08, 0x00, -1 }; int opsc38[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6E, 0x18, 0x10, 0x03, 0x06, 0x00, 0x00, 0x00, @@ -11963,11 +11925,6 @@ offsetCalibration1220p (int color, int *offRed, int *offGreen, int *offBlue) opsc04[4] = 0x1B; opsc04[7] = 0x20; - opsc10[0] = 0x19; - opsc10[1] = 0xD5; - opsc10[4] = 0x1B; - opsc10[7] = 0x20; - opsc48[8] = 0x2B; opsc48[11] = 0x20; opsc48[12] = 0x08; diff --git a/backend/v4l.c b/backend/v4l.c index 519bf01..1e032c7 100644 --- a/backend/v4l.c +++ b/backend/v4l.c @@ -495,13 +495,12 @@ sane_exit (void) } SANE_Status -sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) +sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { V4L_Device *dev; int i; DBG (5, "sane_get_devices\n"); - local_only = SANE_TRUE; /* Avoid compile warning */ if (devlist) free (devlist); @@ -962,7 +961,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) SANE_Status sane_start (SANE_Handle handle) { - int len, loop; + int len; V4L_Scanner *s; char data; @@ -998,6 +997,7 @@ sane_start (SANE_Handle handle) } else { + int loop; s->is_mmap = SANE_TRUE; DBG (3, "sane_start: mmap frame, buffersize: %d bytes, buffers: %d, offset 0 %d\n", @@ -1046,6 +1046,7 @@ sane_start (SANE_Handle handle) /* v4l1 actually returns BGR when we ask for RGB, so convert it */ if (s->pict.palette == VIDEO_PALETTE_RGB24) { + __u32 loop; DBG (3, "sane_start: converting from BGR to RGB\n"); for (loop = 0; loop < (s->window.width * s->window.height * 3); loop += 3) { @@ -1130,22 +1131,15 @@ sane_cancel (SANE_Handle handle) SANE_Status -sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) +sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool non_blocking) { - /* Avoid compile warning */ - handle = 0; - if (non_blocking == SANE_FALSE) return SANE_STATUS_GOOD; return SANE_STATUS_UNSUPPORTED; } SANE_Status -sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) +sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { - /* Avoid compile warning */ - handle = 0; - fd = 0; - return SANE_STATUS_UNSUPPORTED; } diff --git a/backend/xerox_mfp-tcp.c b/backend/xerox_mfp-tcp.c index 2addb0d..845ab7e 100644 --- a/backend/xerox_mfp-tcp.c +++ b/backend/xerox_mfp-tcp.c @@ -47,9 +47,9 @@ #define RECV_TIMEOUT 1 /* seconds */ extern int sanei_debug_xerox_mfp; -int tcp_dev_request (struct device *dev, - SANE_Byte *cmd, size_t cmdlen, - SANE_Byte *resp, size_t *resplen) +int tcp_dev_request(struct device *dev, + SANE_Byte *cmd, size_t cmdlen, + SANE_Byte *resp, size_t *resplen) { size_t bytes_recv = 0; ssize_t rc = 1; @@ -58,46 +58,46 @@ int tcp_dev_request (struct device *dev, /* Send request, if any */ if (cmd && cmdlen) { - len = (size_t)sanei_tcp_write(dev->dn, cmd, cmdlen); - if (len != cmdlen) { - DBG (1, "%s: sent only %lu bytes of %lu\n", - __FUNCTION__, (u_long)len, (u_long)cmdlen); - return SANE_STATUS_IO_ERROR; - } + len = (size_t)sanei_tcp_write(dev->dn, cmd, cmdlen); + if (len != cmdlen) { + DBG(1, "%s: sent only %lu bytes of %lu\n", + __func__, (u_long)len, (u_long)cmdlen); + return SANE_STATUS_IO_ERROR; + } } /* Receive response, if expected */ if (resp && resplen) { - DBG (3, "%s: wait for %i bytes\n", __FUNCTION__, (int)*resplen); - - while (bytes_recv < *resplen && rc > 0) { - rc = recv(dev->dn, resp+bytes_recv, *resplen-bytes_recv, 0); - - if (rc > 0) bytes_recv += rc; - else { - DBG(1, "%s: error %s, bytes requested: %i, bytes read: %i\n", - __FUNCTION__, strerror(errno), (int)*resplen, (int)bytes_recv); - *resplen = bytes_recv; -/* - TODO: - do something smarter than that! -*/ - return SANE_STATUS_GOOD; - return SANE_STATUS_IO_ERROR; - } - } + DBG(3, "%s: wait for %i bytes\n", __func__, (int)*resplen); + + while (bytes_recv < *resplen && rc > 0) { + rc = recv(dev->dn, resp+bytes_recv, *resplen-bytes_recv, 0); + + if (rc > 0) bytes_recv += rc; + else { + DBG(1, "%s: error %s, bytes requested: %i, bytes read: %i\n", + __func__, strerror(errno), (int)*resplen, (int)bytes_recv); + *resplen = bytes_recv; + /* + TODO: + do something smarter than that! + */ + return SANE_STATUS_GOOD; + return SANE_STATUS_IO_ERROR; + } + } } *resplen = bytes_recv; - return SANE_STATUS_GOOD; + return SANE_STATUS_GOOD; } -SANE_Status tcp_dev_open (struct device *dev) +SANE_Status tcp_dev_open(struct device *dev) { SANE_Status status; - char* strhost; - char* strport; + char *strhost; + char *strport; int port; struct servent *sp; struct timeval tv; @@ -105,60 +105,60 @@ SANE_Status tcp_dev_open (struct device *dev) devname = dev->sane.name; - DBG (3, "%s: open %s\n", __FUNCTION__, devname); + DBG(3, "%s: open %s\n", __func__, devname); - if (strncmp (devname, "tcp", 3) != 0) return SANE_STATUS_INVAL; + if (strncmp(devname, "tcp", 3) != 0) return SANE_STATUS_INVAL; devname += 3; - devname = sanei_config_skip_whitespace (devname); + devname = sanei_config_skip_whitespace(devname); if (!*devname) return SANE_STATUS_INVAL; - devname = sanei_config_get_string (devname, &strhost); - devname = sanei_config_skip_whitespace (devname); + devname = sanei_config_get_string(devname, &strhost); + devname = sanei_config_skip_whitespace(devname); if (*devname) - devname = sanei_config_get_string (devname, &strport); + devname = sanei_config_get_string(devname, &strport); else - strport = "9400"; + strport = "9400"; if (isdigit(*strport)) { - port = atoi(strport); + port = atoi(strport); } else { - if ((sp = getservbyname(strport, "tcp"))) { - port = ntohs(sp->s_port); - } else { - DBG (1, "%s: unknown TCP service %s\n", __FUNCTION__, strport); - return SANE_STATUS_IO_ERROR; - } + if ((sp = getservbyname(strport, "tcp"))) { + port = ntohs(sp->s_port); + } else { + DBG(1, "%s: unknown TCP service %s\n", __func__, strport); + return SANE_STATUS_IO_ERROR; + } } status = sanei_tcp_open(strhost, port, &dev->dn); if (status == SANE_STATUS_GOOD) { - tv.tv_sec = RECV_TIMEOUT; - tv.tv_usec = 0; - if (setsockopt (dev->dn, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv) < 0) { - DBG(1, "%s: setsockopts %s", __FUNCTION__, strerror(errno)); - } + tv.tv_sec = RECV_TIMEOUT; + tv.tv_usec = 0; + if (setsockopt(dev->dn, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv) < 0) { + DBG(1, "%s: setsockopts %s", __func__, strerror(errno)); + } } return status; } void -tcp_dev_close (struct device *dev) +tcp_dev_close(struct device *dev) { if (!dev) return; - DBG (3, "%s: closing dev %p\n", __FUNCTION__, (void *)dev); + DBG(3, "%s: closing dev %p\n", __func__, (void *)dev); /* finish all operations */ if (dev->scanning) { - dev->cancel = 1; - /* flush READ_IMAGE data */ - if (dev->reading) sane_read(dev, NULL, 1, NULL); - /* send cancel if not sent before */ - if (dev->state != SANE_STATUS_CANCELLED) - ret_cancel(dev, 0); + dev->cancel = 1; + /* flush READ_IMAGE data */ + if (dev->reading) sane_read(dev, NULL, 1, NULL); + /* send cancel if not sent before */ + if (dev->state != SANE_STATUS_CANCELLED) + ret_cancel(dev, 0); } sanei_tcp_close(dev->dn); @@ -167,15 +167,15 @@ tcp_dev_close (struct device *dev) SANE_Status -tcp_configure_device (const char *devname, SANE_Status (*list_one)(SANE_String_Const devname)) +tcp_configure_device(const char *devname, SANE_Status(*list_one)(SANE_String_Const devname)) { -/* - TODO: LAN scanners multicast discovery. - devname would contain "tcp auto" - - We find new devnames and feed them to - `list_one_device' one by one -*/ + /* + TODO: LAN scanners multicast discovery. + devname would contain "tcp auto" + + We find new devnames and feed them to + `list_one_device' one by one + */ return list_one(devname); } diff --git a/backend/xerox_mfp-usb.c b/backend/xerox_mfp-usb.c index b9b56d8..6ef1eea 100644 --- a/backend/xerox_mfp-usb.c +++ b/backend/xerox_mfp-usb.c @@ -22,90 +22,90 @@ extern int sanei_debug_xerox_mfp; int -usb_dev_request (struct device *dev, - SANE_Byte *cmd, size_t cmdlen, - SANE_Byte *resp, size_t *resplen) +usb_dev_request(struct device *dev, + SANE_Byte *cmd, size_t cmdlen, + SANE_Byte *resp, size_t *resplen) { - SANE_Status status; - size_t len = cmdlen; - - if (cmd && cmdlen) { - status = sanei_usb_write_bulk (dev->dn, cmd, &cmdlen); - if (status != SANE_STATUS_GOOD) { - DBG (1, "%s: sanei_usb_write_bulk: %s\n", __FUNCTION__, - sane_strstatus (status)); - return SANE_STATUS_IO_ERROR; + SANE_Status status; + size_t len = cmdlen; + + if (cmd && cmdlen) { + status = sanei_usb_write_bulk(dev->dn, cmd, &cmdlen); + if (status != SANE_STATUS_GOOD) { + DBG(1, "%s: sanei_usb_write_bulk: %s\n", __func__, + sane_strstatus(status)); + return SANE_STATUS_IO_ERROR; + } + + if (cmdlen != len) { + DBG(1, "%s: sanei_usb_write_bulk: wanted %lu bytes, wrote %lu bytes\n", + __func__, (size_t)len, (size_t)cmdlen); + return SANE_STATUS_IO_ERROR; + } } - if (cmdlen != len) { - DBG (1, "%s: sanei_usb_write_bulk: wanted %lu bytes, wrote %lu bytes\n", - __FUNCTION__, (size_t)len, (size_t)cmdlen); - return SANE_STATUS_IO_ERROR; - } - } - - if (resp && resplen) { - status = sanei_usb_read_bulk (dev->dn, resp, resplen); - if (status != SANE_STATUS_GOOD) { - DBG (1, "%s: sanei_usb_read_bulk: %s\n", __FUNCTION__, - sane_strstatus (status)); - return SANE_STATUS_IO_ERROR; + if (resp && resplen) { + status = sanei_usb_read_bulk(dev->dn, resp, resplen); + if (status != SANE_STATUS_GOOD) { + DBG(1, "%s: sanei_usb_read_bulk: %s\n", __func__, + sane_strstatus(status)); + return SANE_STATUS_IO_ERROR; + } } - } - return SANE_STATUS_GOOD; + return SANE_STATUS_GOOD; } SANE_Status -usb_dev_open (struct device *dev) +usb_dev_open(struct device *dev) { - SANE_Status status; - - DBG (3, "%s: open %p\n", __FUNCTION__, (void *)dev); - status = sanei_usb_open (dev->sane.name, &dev->dn); - if (status != SANE_STATUS_GOOD) { - DBG (1, "%s: sanei_usb_open(%s): %s\n", __FUNCTION__, - dev->sane.name, sane_strstatus (status)); - dev->dn = -1; - return status; + SANE_Status status; + + DBG(3, "%s: open %p\n", __func__, (void *)dev); + status = sanei_usb_open(dev->sane.name, &dev->dn); + if (status != SANE_STATUS_GOOD) { + DBG(1, "%s: sanei_usb_open(%s): %s\n", __func__, + dev->sane.name, sane_strstatus(status)); + dev->dn = -1; + return status; } - sanei_usb_clear_halt (dev->dn); - return SANE_STATUS_GOOD; + sanei_usb_clear_halt(dev->dn); + return SANE_STATUS_GOOD; } void -usb_dev_close (struct device *dev) +usb_dev_close(struct device *dev) { - if (!dev) - return; - DBG (3, "%s: closing dev %p\n", __FUNCTION__, (void *)dev); - - /* finish all operations */ - if (dev->scanning) { - dev->cancel = 1; - /* flush READ_IMAGE data */ - if (dev->reading) - sane_read(dev, NULL, 1, NULL); - /* send cancel if not sent before */ - if (dev->state != SANE_STATUS_CANCELLED) - ret_cancel(dev, 0); - } - - sanei_usb_clear_halt (dev->dn); /* unstall for next users */ - sanei_usb_close (dev->dn); - dev->dn = -1; + if (!dev) + return; + DBG(3, "%s: closing dev %p\n", __func__, (void *)dev); + + /* finish all operations */ + if (dev->scanning) { + dev->cancel = 1; + /* flush READ_IMAGE data */ + if (dev->reading) + sane_read(dev, NULL, 1, NULL); + /* send cancel if not sent before */ + if (dev->state != SANE_STATUS_CANCELLED) + ret_cancel(dev, 0); + } + + sanei_usb_clear_halt(dev->dn); /* unstall for next users */ + sanei_usb_close(dev->dn); + dev->dn = -1; } /* SANE API ignores return code of this callback */ SANE_Status -usb_configure_device (const char *devname, SANE_Status (*attach) (const char *dev)) +usb_configure_device(const char *devname, SANE_Status(*attach)(const char *dev)) { - sanei_usb_set_timeout (1000); - sanei_usb_attach_matching_devices (devname, attach); - sanei_usb_set_timeout (30000); - return SANE_STATUS_GOOD; + sanei_usb_set_timeout(1000); + sanei_usb_attach_matching_devices(devname, attach); + sanei_usb_set_timeout(30000); + return SANE_STATUS_GOOD; } diff --git a/backend/xerox_mfp.c b/backend/xerox_mfp.c index 2ef7078..8b8c895 100644 --- a/backend/xerox_mfp.c +++ b/backend/xerox_mfp.c @@ -1,9 +1,12 @@ /* - * SANE backend for Xerox Phaser 3200MFP - * Copyright 2008 ABC + * SANE backend for Xerox Phaser 3200MFP et al. + * Copyright 2008-2016 ABC * - * Network Scanners Support - * Copyright 2010 Alexander Kuznetsov + * Network Scanners Support + * Copyright 2010 Alexander Kuznetsov + * + * Color scanning on Samsung M2870 model and Xerox Cognac 3215 & 3225 + * models by Laxmeesh Onkar Markod * * This program is licensed under GPL + SANE exception. * More info at http://www.sane-project.org/license.html @@ -30,6 +33,9 @@ #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_backend.h" +#ifdef HAVE_LIBJPEG +#include +#endif #include "xerox_mfp.h" #define BACKEND_BUILD 13 @@ -46,34 +52,34 @@ transport available_transports[TRANSPORTS_MAX] = { static int resolv_state(int state) { - if (state & STATE_DOCUMENT_JAM) - return SANE_STATUS_JAMMED; - if (state & STATE_NO_DOCUMENT) - return SANE_STATUS_NO_DOCS; - if (state & STATE_COVER_OPEN) - return SANE_STATUS_COVER_OPEN; - if (state & STATE_INVALID_AREA) - return SANE_STATUS_INVAL; /* sane_start: implies SANE_INFO_RELOAD_OPTIONS */ - if (state & STATE_WARMING) + if (state & STATE_DOCUMENT_JAM) + return SANE_STATUS_JAMMED; + if (state & STATE_NO_DOCUMENT) + return SANE_STATUS_NO_DOCS; + if (state & STATE_COVER_OPEN) + return SANE_STATUS_COVER_OPEN; + if (state & STATE_INVALID_AREA) + return SANE_STATUS_INVAL; /* sane_start: implies SANE_INFO_RELOAD_OPTIONS */ + if (state & STATE_WARMING) #ifdef SANE_STATUS_WARMING_UP - return SANE_STATUS_WARMING_UP; + return SANE_STATUS_WARMING_UP; #else - return SANE_STATUS_DEVICE_BUSY; + return SANE_STATUS_DEVICE_BUSY; #endif - if (state & STATE_LOCKING) + if (state & STATE_LOCKING) #ifdef SANE_STATUS_HW_LOCKED - return SANE_STATUS_HW_LOCKED; + return SANE_STATUS_HW_LOCKED; #else - return SANE_STATUS_JAMMED; + return SANE_STATUS_JAMMED; #endif - if (state & ~STATE_NO_ERROR) - return SANE_STATUS_DEVICE_BUSY; - return 0; + if (state & ~STATE_NO_ERROR) + return SANE_STATUS_DEVICE_BUSY; + return 0; } static char *str_cmd(int cmd) { - switch (cmd) { + switch (cmd) { case CMD_ABORT: return "ABORT"; case CMD_INQUIRY: return "INQUIRY"; case CMD_RESERVE_UNIT: return "RESERVE_UNIT"; @@ -82,1262 +88,1442 @@ static char *str_cmd(int cmd) case CMD_READ: return "READ"; case CMD_READ_IMAGE: return "READ_IMAGE"; case CMD_OBJECT_POSITION: return "OBJECT_POSITION"; - } - return "unknown"; + } + return "unknown"; } #define MAX_DUMP 70 +const char *encTmpFileName = "/tmp/stmp_enc.tmp"; + +static int decompress(struct device __sane_unused__ *dev, + const char __sane_unused__ *infilename) +{ +#ifdef HAVE_LIBJPEG + int rc; + int row_stride, width, height, pixel_size; + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + unsigned long bmp_size = 0; + FILE *pInfile = NULL; + JSAMPARRAY buffer; + + if ((pInfile = fopen(infilename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", infilename); + return -1; + } + + cinfo.err = jpeg_std_error(&jerr); + + jpeg_create_decompress(&cinfo); + + jpeg_stdio_src(&cinfo, pInfile); + + rc = jpeg_read_header(&cinfo, TRUE); + if (rc != 1) { + jpeg_destroy_decompress(&cinfo); + fclose(pInfile); + return -1; + } + + jpeg_start_decompress(&cinfo); + + width = cinfo.output_width; + height = cinfo.output_height; + pixel_size = cinfo.output_components; + bmp_size = width * height * pixel_size; + dev->decDataSize = bmp_size; + + row_stride = width * pixel_size; + + buffer = (*cinfo.mem->alloc_sarray) + ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); + + while (cinfo.output_scanline < cinfo.output_height) { + buffer[0] = dev->decData + \ + (cinfo.output_scanline) * row_stride; + jpeg_read_scanlines(&cinfo, buffer, 1); + } + jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + fclose(pInfile); + return 0; +#else + return -1; +#endif +} + +static int copy_decompress_data(struct device *dev, unsigned char *pDest, int maxlen, int *destLen) +{ + int data_size = 0; + size_t result = 0, retVal = 0; + + + if (0 == dev->decDataSize) { + *destLen = 0; + return retVal; + } + data_size = dev->decDataSize - dev->currentDecDataIndex; + if (data_size > maxlen) { + data_size = maxlen; + } + memcpy(pDest, dev->decData+dev->currentDecDataIndex, data_size); + result = data_size; + *destLen = result; + dev->currentDecDataIndex += result; + retVal = result; + + if (dev->decDataSize == dev->currentDecDataIndex) { + dev->currentDecDataIndex = 0; + dev->decDataSize = 0; + } + + return retVal; +} + +static int decompress_tempfile(struct device *dev) +{ + decompress(dev, encTmpFileName); + remove(encTmpFileName); + return 0; +} + +static int dump_to_tmp_file(struct device *dev) +{ + unsigned char *pSrc = dev->data; + int srcLen = dev->datalen; + FILE *pInfile; + if ((pInfile = fopen(encTmpFileName, "a")) == NULL) { + fprintf(stderr, "can't open %s\n", encTmpFileName); + return 0; + } + + fwrite(pSrc, 1, srcLen, pInfile); + fclose(pInfile); + return srcLen; +} + +static int isSupportedDevice(struct device __sane_unused__ *dev) +{ +#ifdef HAVE_LIBJPEG + /* Checking device which supports JPEG Lossy compression for color scanning*/ + if (dev->compressionTypes & (1 << 6)) + return 1; + else + return 0; +#else + return 0; +#endif +} + static void dbg_dump(struct device *dev) { - int i; - char dbuf[MAX_DUMP * 3 + 1], *dptr = dbuf; - int nzlen = dev->reslen; - int dlen = MIN(dev->reslen, MAX_DUMP); + int i; + char dbuf[MAX_DUMP * 3 + 1], *dptr = dbuf; + int nzlen = dev->reslen; + int dlen = MIN(dev->reslen, MAX_DUMP); - for (i = dev->reslen - 1; i >= 0; i--, nzlen--) - if (dev->res[i] != 0) - break; + for (i = dev->reslen - 1; i >= 0; i--, nzlen--) + if (dev->res[i] != 0) + break; - dlen = MIN(dlen, nzlen + 1); + dlen = MIN(dlen, nzlen + 1); - for (i = 0; i < dlen; i++, dptr += 3) - sprintf(dptr, " %02x", dev->res[i]); + for (i = 0; i < dlen; i++, dptr += 3) + sprintf(dptr, " %02x", dev->res[i]); - DBG (5, "[%lu]%s%s\n", (u_long)dev->reslen, dbuf, - (dlen < (int)dev->reslen)? "..." : ""); + DBG(5, "[%lu]%s%s\n", (u_long)dev->reslen, dbuf, + (dlen < (int)dev->reslen)? "..." : ""); } /* one command to device */ /* return 0: on error, 1: success */ -static int dev_command (struct device *dev, SANE_Byte * cmd, size_t reqlen) +static int dev_command(struct device *dev, SANE_Byte *cmd, size_t reqlen) { - SANE_Status status; - size_t sendlen = cmd[3] + 4; - SANE_Byte *res = dev->res; - - - assert (reqlen <= sizeof (dev->res)); /* requested len */ - dev->reslen = sizeof (dev->res); /* doing full buffer to flush stalled commands */ - - if (cmd[2] == CMD_SET_WINDOW) { - /* Set Window have wrong packet length, huh. */ - sendlen = 25; - } - - if (cmd[2] == CMD_READ_IMAGE) { - /* Read Image is raw data, don't need to read response */ - res = NULL; - } - - dev->state = 0; - DBG (4, ":: dev_command(%s[%#x], %lu)\n", str_cmd(cmd[2]), cmd[2], - (u_long)reqlen); - status = dev->io->dev_request(dev, cmd, sendlen, res, &dev->reslen); - if (status != SANE_STATUS_GOOD) { - DBG (1, "%s: dev_request: %s\n", __FUNCTION__, sane_strstatus (status)); - dev->state = SANE_STATUS_IO_ERROR; - return 0; - } + SANE_Status status; + size_t sendlen = cmd[3] + 4; + SANE_Byte *res = dev->res; - if (!res) { - /* if not need response just return success */ - return 1; - } - /* normal command reply, some sanity checking */ - if (dev->reslen < reqlen) { - DBG (1, "%s: illegal response len %lu, need %lu\n", - __FUNCTION__, (u_long)dev->reslen, (u_long)reqlen); - dev->state = SANE_STATUS_IO_ERROR; - return 0; - } else { - size_t pktlen; /* len specified in packet */ + assert(reqlen <= sizeof(dev->res)); /* requested len */ + dev->reslen = sizeof(dev->res); /* doing full buffer to flush stalled commands */ - if (DBG_LEVEL > 3) - dbg_dump(dev); + if (cmd[2] == CMD_SET_WINDOW) { + /* Set Window have wrong packet length, huh. */ + sendlen = 25; + } - if (dev->res[0] != RES_CODE) { - DBG (2, "%s: illegal data header %02x\n", __FUNCTION__, dev->res[0]); - dev->state = SANE_STATUS_IO_ERROR; - return 0; + if (cmd[2] == CMD_READ_IMAGE) { + /* Read Image is raw data, don't need to read response */ + res = NULL; } - pktlen = dev->res[2] + 3; - if (dev->reslen != pktlen) { - DBG (2, "%s: illegal response len %lu, should be %lu\n", - __FUNCTION__, (u_long)pktlen, (u_long)dev->reslen); - dev->state = SANE_STATUS_IO_ERROR; - return 0; + + dev->state = 0; + DBG(4, ":: dev_command(%s[%#x], %lu)\n", str_cmd(cmd[2]), cmd[2], + (u_long)reqlen); + status = dev->io->dev_request(dev, cmd, sendlen, res, &dev->reslen); + if (status != SANE_STATUS_GOOD) { + DBG(1, "%s: dev_request: %s\n", __func__, sane_strstatus(status)); + dev->state = SANE_STATUS_IO_ERROR; + return 0; } - if (dev->reslen > reqlen) - DBG (2, "%s: too big packet len %lu, need %lu\n", - __FUNCTION__, (u_long)dev->reslen, (u_long)reqlen); - } - - dev->state = 0; - if (cmd[2] == CMD_SET_WINDOW || - cmd[2] == CMD_OBJECT_POSITION || - cmd[2] == CMD_READ || - cmd[2] == CMD_RESERVE_UNIT) { - if (dev->res[1] == STATUS_BUSY) - dev->state = SANE_STATUS_DEVICE_BUSY; - else if (dev->res[1] == STATUS_CANCEL) - dev->state = SANE_STATUS_CANCELLED; - else if (dev->res[1] == STATUS_CHECK) - dev->state = resolv_state((cmd[2] == CMD_READ)? - (dev->res[12] << 8 | dev->res[13]) : - (dev->res[4] << 8 | dev->res[5])); - - if (dev->state) - DBG (3, "%s(%s[%#x]): => %d: %s\n", - __FUNCTION__, str_cmd(cmd[2]), cmd[2], - dev->state, sane_strstatus(dev->state)); - } - - return 1; + + if (!res) { + /* if not need response just return success */ + return 1; + } + + /* normal command reply, some sanity checking */ + if (dev->reslen < reqlen) { + DBG(1, "%s: illegal response len %lu, need %lu\n", + __func__, (u_long)dev->reslen, (u_long)reqlen); + dev->state = SANE_STATUS_IO_ERROR; + return 0; + } else { + size_t pktlen; /* len specified in packet */ + + if (DBG_LEVEL > 3) + dbg_dump(dev); + + if (dev->res[0] != RES_CODE) { + DBG(2, "%s: illegal data header %02x\n", __func__, dev->res[0]); + dev->state = SANE_STATUS_IO_ERROR; + return 0; + } + pktlen = dev->res[2] + 3; + if (dev->reslen != pktlen) { + DBG(2, "%s: illegal response len %lu, should be %lu\n", + __func__, (u_long)pktlen, (u_long)dev->reslen); + dev->state = SANE_STATUS_IO_ERROR; + return 0; + } + if (dev->reslen > reqlen) + DBG(2, "%s: too big packet len %lu, need %lu\n", + __func__, (u_long)dev->reslen, (u_long)reqlen); + } + + dev->state = 0; + if (cmd[2] == CMD_SET_WINDOW || + cmd[2] == CMD_OBJECT_POSITION || + cmd[2] == CMD_READ || + cmd[2] == CMD_RESERVE_UNIT) { + if (dev->res[1] == STATUS_BUSY) + dev->state = SANE_STATUS_DEVICE_BUSY; + else if (dev->res[1] == STATUS_CANCEL) + dev->state = SANE_STATUS_CANCELLED; + else if (dev->res[1] == STATUS_CHECK) + dev->state = resolv_state((cmd[2] == CMD_READ)? + (dev->res[12] << 8 | dev->res[13]) : + (dev->res[4] << 8 | dev->res[5])); + + if (dev->state) + DBG(3, "%s(%s[%#x]): => %d: %s\n", + __func__, str_cmd(cmd[2]), cmd[2], + dev->state, sane_strstatus(dev->state)); + } + + return 1; } /* one short command to device */ -static int dev_cmd (struct device *dev, SANE_Byte command) +static int dev_cmd(struct device *dev, SANE_Byte command) { - SANE_Byte cmd[4] = { REQ_CODE_A, REQ_CODE_B }; - cmd[2] = command; - return dev_command (dev, cmd, (command == CMD_INQUIRY)? 70 : 32); + SANE_Byte cmd[4] = { REQ_CODE_A, REQ_CODE_B }; + cmd[2] = command; + return dev_command(dev, cmd, (command == CMD_INQUIRY)? 70 : 32); } /* stop scanning operation. return previous status */ static SANE_Status dev_stop(struct device *dev) { - int state = dev->state; - - DBG (3, "%s: %p, scanning %d, reserved %d\n", __FUNCTION__, - (void *)dev, dev->scanning, dev->reserved); - dev->scanning = 0; - - /* release */ - if (!dev->reserved) - return state; - dev->reserved = 0; - dev_cmd(dev, CMD_RELEASE_UNIT); - DBG (3, "total image %d*%d size %d (win %d*%d), %d*%d %d data: %d, out %d bytes\n", - dev->para.pixels_per_line, dev->para.lines, - dev->total_img_size, - dev->win_width, dev->win_len, - dev->pixels_per_line, dev->ulines, dev->blocks, - dev->total_data_size, dev->total_out_size); - dev->state = state; - return state; + int state = dev->state; + + DBG(3, "%s: %p, scanning %d, reserved %d\n", __func__, + (void *)dev, dev->scanning, dev->reserved); + dev->scanning = 0; + + /* release */ + if (!dev->reserved) + return state; + dev->reserved = 0; + dev_cmd(dev, CMD_RELEASE_UNIT); + DBG(3, "total image %d*%d size %d (win %d*%d), %d*%d %d data: %d, out %d bytes\n", + dev->para.pixels_per_line, dev->para.lines, + dev->total_img_size, + dev->win_width, dev->win_len, + dev->pixels_per_line, dev->ulines, dev->blocks, + dev->total_data_size, dev->total_out_size); + dev->state = state; + return state; } SANE_Status ret_cancel(struct device *dev, SANE_Status ret) { - dev_cmd(dev, CMD_ABORT); - if (dev->scanning) { - dev_stop(dev); - dev->state = SANE_STATUS_CANCELLED; - } - return ret; + dev_cmd(dev, CMD_ABORT); + if (dev->scanning) { + dev_stop(dev); + dev->state = SANE_STATUS_CANCELLED; + } + return ret; } static int cancelled(struct device *dev) { - if (dev->cancel) - return ret_cancel(dev, 1); - return 0; + if (dev->cancel) + return ret_cancel(dev, 1); + return 0; } /* issue command and wait until scanner is not busy */ /* return 0 on error/blocking, 1 is ok and ready */ static int dev_cmd_wait(struct device *dev, int cmd) { - int sleeptime = 10; - - do { - if (cancelled(dev)) - return 0; - if (!dev_cmd(dev, cmd)) { - dev->state = SANE_STATUS_IO_ERROR; - return 0; - } else if (dev->state) { - if (dev->state != SANE_STATUS_DEVICE_BUSY) - return 0; - else { - if (dev->non_blocking) { - dev->state = SANE_STATUS_GOOD; - return 0; - } else { - if (sleeptime > 1000) - sleeptime = 1000; - DBG (4, "(%s) sleeping(%d ms).. [%x %x]\n", - str_cmd(cmd), sleeptime, dev->res[4], dev->res[5]); - usleep(sleeptime * 1000); - if (sleeptime < 1000) - sleeptime *= (sleeptime < 100)? 10 : 2; - } - } /* BUSY */ - } - } while (dev->state == SANE_STATUS_DEVICE_BUSY); + int sleeptime = 10; + + do { + if (cancelled(dev)) + return 0; + if (!dev_cmd(dev, cmd)) { + dev->state = SANE_STATUS_IO_ERROR; + return 0; + } else if (dev->state) { + if (dev->state != SANE_STATUS_DEVICE_BUSY) + return 0; + else { + if (dev->non_blocking) { + dev->state = SANE_STATUS_GOOD; + return 0; + } else { + if (sleeptime > 1000) + sleeptime = 1000; + DBG(4, "(%s) sleeping(%d ms).. [%x %x]\n", + str_cmd(cmd), sleeptime, dev->res[4], dev->res[5]); + usleep(sleeptime * 1000); + if (sleeptime < 1000) + sleeptime *= (sleeptime < 100)? 10 : 2; + } + } /* BUSY */ + } + } while (dev->state == SANE_STATUS_DEVICE_BUSY); - return 1; + return 1; } static int inq_dpi_bits[] = { - 75, 150, 0, 0, - 200, 300, 0, 0, - 600, 0, 0, 1200, - 100, 0, 0, 2400, - 0, 4800, 0, 9600 + 75, 150, 0, 0, + 200, 300, 0, 0, + 600, 0, 0, 1200, + 100, 0, 0, 2400, + 0, 4800, 0, 9600 }; static int res_dpi_codes[] = { - 75, 0, 150, 0, - 0, 300, 0, 600, - 1200, 200, 100, 2400, - 4800, 9600 + 75, 0, 150, 0, + 0, 300, 0, 600, + 1200, 200, 100, 2400, + 4800, 9600 }; -static int SANE_Word_sort(const void * a, const void * b) +static int SANE_Word_sort(const void *a, const void *b) { - return *(const SANE_Word *)a - *(const SANE_Word *)b; + return *(const SANE_Word *)a - *(const SANE_Word *)b; } /* resolve inquired dpi list to dpi_list array */ static void resolv_inq_dpi(struct device *dev) { - unsigned int i; - int res = dev->resolutions; - - assert(sizeof(inq_dpi_bits) < sizeof(dev->dpi_list)); - for (i = 0; i < sizeof(inq_dpi_bits) / sizeof(int); i++) - if (inq_dpi_bits[i] && (res & (1 << i))) - dev->dpi_list[++dev->dpi_list[0]] = inq_dpi_bits[i]; - qsort(&dev->dpi_list[1], dev->dpi_list[0], sizeof(SANE_Word), SANE_Word_sort); + unsigned int i; + int res = dev->resolutions; + + assert(sizeof(inq_dpi_bits) < sizeof(dev->dpi_list)); + for (i = 0; i < sizeof(inq_dpi_bits) / sizeof(int); i++) + if (inq_dpi_bits[i] && (res & (1 << i))) + dev->dpi_list[++dev->dpi_list[0]] = inq_dpi_bits[i]; + qsort(&dev->dpi_list[1], dev->dpi_list[0], sizeof(SANE_Word), SANE_Word_sort); } static unsigned int dpi_to_code(int dpi) { - unsigned int i; + unsigned int i; - for (i = 0; i < sizeof(res_dpi_codes) / sizeof(int); i++) { - if (dpi == res_dpi_codes[i]) - return i; - } - return 0; + for (i = 0; i < sizeof(res_dpi_codes) / sizeof(int); i++) { + if (dpi == res_dpi_codes[i]) + return i; + } + return 0; } static int string_match_index(const SANE_String_Const s[], SANE_String m) { - int i; - - for (i = 0; *s; i++) { - SANE_String_Const x = *s++; - if (strcasecmp(x, m) == 0) - return i; - } - return 0; + int i; + + for (i = 0; *s; i++) { + SANE_String_Const x = *s++; + if (strcasecmp(x, m) == 0) + return i; + } + return 0; } static SANE_String string_match(const SANE_String_Const s[], SANE_String m) { - return UNCONST(s[string_match_index(s, m)]); + return UNCONST(s[string_match_index(s, m)]); } -static size_t max_string_size (SANE_String_Const s[]) +static size_t max_string_size(SANE_String_Const s[]) { - size_t max = 0; - - while (*s) { - size_t size = strlen(*s++) + 1; - if (size > max) - max = size; - } - return max; + size_t max = 0; + + while (*s) { + size_t size = strlen(*s++) + 1; + if (size > max) + max = size; + } + return max; } static SANE_String_Const doc_sources[] = { - "Flatbed", "ADF", "Auto", NULL + "Flatbed", "ADF", "Auto", NULL }; static int doc_source_to_code[] = { - 0x40, 0x20, 0x80 + 0x40, 0x20, 0x80 }; static SANE_String_Const scan_modes[] = { - SANE_VALUE_SCAN_MODE_LINEART, - SANE_VALUE_SCAN_MODE_HALFTONE, - SANE_VALUE_SCAN_MODE_GRAY, - SANE_VALUE_SCAN_MODE_COLOR, - NULL + SANE_VALUE_SCAN_MODE_LINEART, + SANE_VALUE_SCAN_MODE_HALFTONE, + SANE_VALUE_SCAN_MODE_GRAY, + SANE_VALUE_SCAN_MODE_COLOR, + NULL }; static int scan_mode_to_code[] = { - 0x00, 0x01, 0x03, 0x05 + 0x00, 0x01, 0x03, 0x05 }; static SANE_Range threshold = { - SANE_FIX(30), SANE_FIX(70), SANE_FIX(10) + SANE_FIX(30), SANE_FIX(70), SANE_FIX(10) }; static void reset_options(struct device *dev) { - dev->val[OPT_RESOLUTION].w = 150; - dev->val[OPT_MODE].s = string_match(scan_modes, SANE_VALUE_SCAN_MODE_COLOR); - - /* if docs loaded in adf use it as default source, flatbed oterwise */ - dev->val[OPT_SOURCE].s = UNCONST(doc_sources[(dev->doc_loaded)? 1 : 0]); - - dev->val[OPT_THRESHOLD].w = SANE_FIX(50); - - /* this is reported maximum window size, will be fixed later */ - dev->win_x_range.min = SANE_FIX(0); - dev->win_x_range.max = SANE_FIX((double)dev->max_win_width / PNT_PER_MM); - dev->win_x_range.quant = SANE_FIX(1); - dev->win_y_range.min = SANE_FIX(0); - dev->win_y_range.max = SANE_FIX((double)dev->max_win_len / PNT_PER_MM); - dev->win_y_range.quant = SANE_FIX(1); - dev->val[OPT_SCAN_TL_X].w = dev->win_x_range.min; - dev->val[OPT_SCAN_TL_Y].w = dev->win_y_range.min; - dev->val[OPT_SCAN_BR_X].w = dev->win_x_range.max; - dev->val[OPT_SCAN_BR_Y].w = dev->win_y_range.max; + dev->val[OPT_RESOLUTION].w = 150; + dev->val[OPT_MODE].s = string_match(scan_modes, SANE_VALUE_SCAN_MODE_COLOR); + + /* if docs loaded in adf use it as default source, flatbed oterwise */ + dev->val[OPT_SOURCE].s = UNCONST(doc_sources[(dev->doc_loaded)? 1 : 0]); + + dev->val[OPT_THRESHOLD].w = SANE_FIX(50); + + /* this is reported maximum window size, will be fixed later */ + dev->win_x_range.min = SANE_FIX(0); + dev->win_x_range.max = SANE_FIX((double)dev->max_win_width / PNT_PER_MM); + dev->win_x_range.quant = SANE_FIX(1); + dev->win_y_range.min = SANE_FIX(0); + dev->win_y_range.max = SANE_FIX((double)dev->max_win_len / PNT_PER_MM); + dev->win_y_range.quant = SANE_FIX(1); + dev->val[OPT_SCAN_TL_X].w = dev->win_x_range.min; + dev->val[OPT_SCAN_TL_Y].w = dev->win_y_range.min; + dev->val[OPT_SCAN_BR_X].w = dev->win_x_range.max; + dev->val[OPT_SCAN_BR_Y].w = dev->win_y_range.max; } static void init_options(struct device *dev) { - int i; - - for (i = 0; i < NUM_OPTIONS; i++) { - dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; - dev->opt[i].size = sizeof(SANE_Word); - dev->opt[i].type = SANE_TYPE_FIXED; - dev->val[i].s = NULL; - } - - dev->opt[OPT_NUMOPTIONS].name = SANE_NAME_NUM_OPTIONS; - dev->opt[OPT_NUMOPTIONS].title = SANE_TITLE_NUM_OPTIONS; - dev->opt[OPT_NUMOPTIONS].desc = SANE_DESC_NUM_OPTIONS; - dev->opt[OPT_NUMOPTIONS].type = SANE_TYPE_INT; - dev->opt[OPT_NUMOPTIONS].cap = SANE_CAP_SOFT_DETECT; - dev->val[OPT_NUMOPTIONS].w = NUM_OPTIONS; - - dev->opt[OPT_GROUP_STD].name = SANE_NAME_STANDARD; - dev->opt[OPT_GROUP_STD].title = SANE_TITLE_STANDARD; - dev->opt[OPT_GROUP_STD].desc = SANE_DESC_STANDARD; - dev->opt[OPT_GROUP_STD].type = SANE_TYPE_GROUP; - dev->opt[OPT_GROUP_STD].cap = 0; - - dev->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; - dev->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; - dev->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; - dev->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; - dev->opt[OPT_RESOLUTION].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; - dev->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; - dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; - dev->opt[OPT_RESOLUTION].constraint.word_list = dev->dpi_list; - - dev->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; - dev->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; - dev->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; - dev->opt[OPT_MODE].type = SANE_TYPE_STRING; - dev->opt[OPT_MODE].size = max_string_size(scan_modes); - dev->opt[OPT_MODE].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; - dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; - dev->opt[OPT_MODE].constraint.string_list = scan_modes; - - dev->opt[OPT_THRESHOLD].name = SANE_NAME_HIGHLIGHT; - dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; - dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; - dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; - dev->opt[OPT_THRESHOLD].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; - dev->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; - dev->opt[OPT_THRESHOLD].constraint.range = &threshold; - - dev->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; - dev->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; - dev->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; - dev->opt[OPT_SOURCE].type = SANE_TYPE_STRING; - dev->opt[OPT_SOURCE].size = max_string_size(doc_sources); - dev->opt[OPT_SOURCE].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; - dev->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; - dev->opt[OPT_SOURCE].constraint.string_list = doc_sources; - - dev->opt[OPT_GROUP_GEO].name = SANE_NAME_GEOMETRY; - dev->opt[OPT_GROUP_GEO].title = SANE_TITLE_GEOMETRY; - dev->opt[OPT_GROUP_GEO].desc = SANE_DESC_GEOMETRY; - dev->opt[OPT_GROUP_GEO].type = SANE_TYPE_GROUP; - dev->opt[OPT_GROUP_GEO].cap = 0; - - dev->opt[OPT_SCAN_TL_X].name = SANE_NAME_SCAN_TL_X; - dev->opt[OPT_SCAN_TL_X].title = SANE_TITLE_SCAN_TL_X; - dev->opt[OPT_SCAN_TL_X].desc = SANE_DESC_SCAN_TL_X; - dev->opt[OPT_SCAN_TL_X].unit = SANE_UNIT_MM; - dev->opt[OPT_SCAN_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; - dev->opt[OPT_SCAN_TL_X].constraint.range = &dev->win_x_range; - - dev->opt[OPT_SCAN_TL_Y].name = SANE_NAME_SCAN_TL_Y; - dev->opt[OPT_SCAN_TL_Y].title = SANE_TITLE_SCAN_TL_Y; - dev->opt[OPT_SCAN_TL_Y].desc = SANE_DESC_SCAN_TL_Y; - dev->opt[OPT_SCAN_TL_Y].unit = SANE_UNIT_MM; - dev->opt[OPT_SCAN_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; - dev->opt[OPT_SCAN_TL_Y].constraint.range = &dev->win_y_range; - - dev->opt[OPT_SCAN_BR_X].name = SANE_NAME_SCAN_BR_X; - dev->opt[OPT_SCAN_BR_X].title = SANE_TITLE_SCAN_BR_X; - dev->opt[OPT_SCAN_BR_X].desc = SANE_DESC_SCAN_BR_X; - dev->opt[OPT_SCAN_BR_X].unit = SANE_UNIT_MM; - dev->opt[OPT_SCAN_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; - dev->opt[OPT_SCAN_BR_X].constraint.range = &dev->win_x_range; - - dev->opt[OPT_SCAN_BR_Y].name = SANE_NAME_SCAN_BR_Y; - dev->opt[OPT_SCAN_BR_Y].title = SANE_TITLE_SCAN_BR_Y; - dev->opt[OPT_SCAN_BR_Y].desc = SANE_DESC_SCAN_BR_Y; - dev->opt[OPT_SCAN_BR_Y].unit = SANE_UNIT_MM; - dev->opt[OPT_SCAN_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; - dev->opt[OPT_SCAN_BR_Y].constraint.range = &dev->win_y_range; + int i; + + for (i = 0; i < NUM_OPTIONS; i++) { + dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; + dev->opt[i].size = sizeof(SANE_Word); + dev->opt[i].type = SANE_TYPE_FIXED; + dev->val[i].s = NULL; + } + + dev->opt[OPT_NUMOPTIONS].name = SANE_NAME_NUM_OPTIONS; + dev->opt[OPT_NUMOPTIONS].title = SANE_TITLE_NUM_OPTIONS; + dev->opt[OPT_NUMOPTIONS].desc = SANE_DESC_NUM_OPTIONS; + dev->opt[OPT_NUMOPTIONS].type = SANE_TYPE_INT; + dev->opt[OPT_NUMOPTIONS].cap = SANE_CAP_SOFT_DETECT; + dev->val[OPT_NUMOPTIONS].w = NUM_OPTIONS; + + dev->opt[OPT_GROUP_STD].name = SANE_NAME_STANDARD; + dev->opt[OPT_GROUP_STD].title = SANE_TITLE_STANDARD; + dev->opt[OPT_GROUP_STD].desc = SANE_DESC_STANDARD; + dev->opt[OPT_GROUP_STD].type = SANE_TYPE_GROUP; + dev->opt[OPT_GROUP_STD].cap = 0; + + dev->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; + dev->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; + dev->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; + dev->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; + dev->opt[OPT_RESOLUTION].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; + dev->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; + dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; + dev->opt[OPT_RESOLUTION].constraint.word_list = dev->dpi_list; + + dev->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; + dev->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; + dev->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; + dev->opt[OPT_MODE].type = SANE_TYPE_STRING; + dev->opt[OPT_MODE].size = max_string_size(scan_modes); + dev->opt[OPT_MODE].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; + dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; + dev->opt[OPT_MODE].constraint.string_list = scan_modes; + + dev->opt[OPT_THRESHOLD].name = SANE_NAME_HIGHLIGHT; + dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; + dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; + dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; + dev->opt[OPT_THRESHOLD].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; + dev->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; + dev->opt[OPT_THRESHOLD].constraint.range = &threshold; + + dev->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; + dev->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; + dev->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; + dev->opt[OPT_SOURCE].type = SANE_TYPE_STRING; + dev->opt[OPT_SOURCE].size = max_string_size(doc_sources); + dev->opt[OPT_SOURCE].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; + dev->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; + dev->opt[OPT_SOURCE].constraint.string_list = doc_sources; + + dev->opt[OPT_GROUP_GEO].name = SANE_NAME_GEOMETRY; + dev->opt[OPT_GROUP_GEO].title = SANE_TITLE_GEOMETRY; + dev->opt[OPT_GROUP_GEO].desc = SANE_DESC_GEOMETRY; + dev->opt[OPT_GROUP_GEO].type = SANE_TYPE_GROUP; + dev->opt[OPT_GROUP_GEO].cap = 0; + + dev->opt[OPT_SCAN_TL_X].name = SANE_NAME_SCAN_TL_X; + dev->opt[OPT_SCAN_TL_X].title = SANE_TITLE_SCAN_TL_X; + dev->opt[OPT_SCAN_TL_X].desc = SANE_DESC_SCAN_TL_X; + dev->opt[OPT_SCAN_TL_X].unit = SANE_UNIT_MM; + dev->opt[OPT_SCAN_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; + dev->opt[OPT_SCAN_TL_X].constraint.range = &dev->win_x_range; + + dev->opt[OPT_SCAN_TL_Y].name = SANE_NAME_SCAN_TL_Y; + dev->opt[OPT_SCAN_TL_Y].title = SANE_TITLE_SCAN_TL_Y; + dev->opt[OPT_SCAN_TL_Y].desc = SANE_DESC_SCAN_TL_Y; + dev->opt[OPT_SCAN_TL_Y].unit = SANE_UNIT_MM; + dev->opt[OPT_SCAN_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; + dev->opt[OPT_SCAN_TL_Y].constraint.range = &dev->win_y_range; + + dev->opt[OPT_SCAN_BR_X].name = SANE_NAME_SCAN_BR_X; + dev->opt[OPT_SCAN_BR_X].title = SANE_TITLE_SCAN_BR_X; + dev->opt[OPT_SCAN_BR_X].desc = SANE_DESC_SCAN_BR_X; + dev->opt[OPT_SCAN_BR_X].unit = SANE_UNIT_MM; + dev->opt[OPT_SCAN_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; + dev->opt[OPT_SCAN_BR_X].constraint.range = &dev->win_x_range; + + dev->opt[OPT_SCAN_BR_Y].name = SANE_NAME_SCAN_BR_Y; + dev->opt[OPT_SCAN_BR_Y].title = SANE_TITLE_SCAN_BR_Y; + dev->opt[OPT_SCAN_BR_Y].desc = SANE_DESC_SCAN_BR_Y; + dev->opt[OPT_SCAN_BR_Y].unit = SANE_UNIT_MM; + dev->opt[OPT_SCAN_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; + dev->opt[OPT_SCAN_BR_Y].constraint.range = &dev->win_y_range; } /* fill parameters from options */ static void set_parameters(struct device *dev) { - double px_to_len; + double px_to_len; - dev->para.last_frame = SANE_TRUE; - dev->para.lines = -1; - px_to_len = 1200.0 / dev->val[OPT_RESOLUTION].w; + dev->para.last_frame = SANE_TRUE; + dev->para.lines = -1; + px_to_len = 1200.0 / dev->val[OPT_RESOLUTION].w; #define BETTER_BASEDPI 1 - /* tests prove that 1200dpi base is very inexact - * so I calculated better values for each axis */ -#if BETTER_BASEDPI - px_to_len = 1180.0 / dev->val[OPT_RESOLUTION].w; -#endif - dev->para.pixels_per_line = dev->win_width / px_to_len; - dev->para.bytes_per_line = dev->para.pixels_per_line; + /* tests prove that 1200dpi base is very inexact + * so I calculated better values for each axis */ #if BETTER_BASEDPI - px_to_len = 1213.9 / dev->val[OPT_RESOLUTION].w; + px_to_len = 1180.0 / dev->val[OPT_RESOLUTION].w; #endif - dev->para.lines = dev->win_len / px_to_len; - if (dev->composition == MODE_LINEART || - dev->composition == MODE_HALFTONE) { - dev->para.format = SANE_FRAME_GRAY; - dev->para.depth = 1; - dev->para.bytes_per_line = (dev->para.pixels_per_line + 7) / 8; - } else if (dev->composition == MODE_GRAY8) { - dev->para.format = SANE_FRAME_GRAY; - dev->para.depth = 8; + dev->para.pixels_per_line = dev->win_width / px_to_len; dev->para.bytes_per_line = dev->para.pixels_per_line; - } else if (dev->composition == MODE_RGB24) { - dev->para.format = SANE_FRAME_RGB; - dev->para.depth = 8; - dev->para.bytes_per_line *= 3; - } else { - /* this will never happen */ - DBG (1, "%s: impossible image composition %d\n", - __FUNCTION__, dev->composition); - dev->para.format = SANE_FRAME_GRAY; - dev->para.depth = 8; - } + + if (!isSupportedDevice(dev)) { +#if BETTER_BASEDPI + px_to_len = 1213.9 / dev->val[OPT_RESOLUTION].w; +#endif + } + dev->para.lines = dev->win_len / px_to_len; + if (dev->composition == MODE_LINEART || + dev->composition == MODE_HALFTONE) { + dev->para.format = SANE_FRAME_GRAY; + dev->para.depth = 1; + dev->para.bytes_per_line = (dev->para.pixels_per_line + 7) / 8; + } else if (dev->composition == MODE_GRAY8) { + dev->para.format = SANE_FRAME_GRAY; + dev->para.depth = 8; + dev->para.bytes_per_line = dev->para.pixels_per_line; + } else if (dev->composition == MODE_RGB24) { + dev->para.format = SANE_FRAME_RGB; + dev->para.depth = 8; + dev->para.bytes_per_line *= 3; + } else { + /* this will never happen */ + DBG(1, "%s: impossible image composition %d\n", + __func__, dev->composition); + dev->para.format = SANE_FRAME_GRAY; + dev->para.depth = 8; + } } /* resolve all options related to scan window */ /* called after option changed and in set_window */ static int fix_window(struct device *dev) { - double win_width_mm, win_len_mm; - int i; - int threshold = SANE_UNFIX(dev->val[OPT_THRESHOLD].w); - - dev->resolution = dpi_to_code(dev->val[OPT_RESOLUTION].w); - dev->composition = scan_mode_to_code[string_match_index(scan_modes, dev->val[OPT_MODE].s)]; - - if (dev->composition == MODE_LINEART || - dev->composition == MODE_HALFTONE) { - dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; - } else { - dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; - } - if (threshold < 30) { - dev->val[OPT_THRESHOLD].w = SANE_FIX(30); - } else if (threshold > 70) { - dev->val[OPT_THRESHOLD].w = SANE_FIX(70); - } - threshold = SANE_UNFIX(dev->val[OPT_THRESHOLD].w); - dev->threshold = (threshold - 30) / 10; - dev->val[OPT_THRESHOLD].w = SANE_FIX(dev->threshold * 10 + 30); - - dev->doc_source = doc_source_to_code[string_match_index(doc_sources, dev->val[OPT_SOURCE].s)]; - - /* max window len is dependent of document source */ - if (dev->doc_source == DOC_FLATBED || - (dev->doc_source == DOC_AUTO && !dev->doc_loaded)) - dev->max_len = dev->max_len_fb; - else - dev->max_len = dev->max_len_adf; - - /* parameters */ - dev->win_y_range.max = SANE_FIX((double)dev->max_len / PNT_PER_MM); - - /* window sanity checking */ - for (i = OPT_SCAN_TL_X; i <= OPT_SCAN_BR_Y; i++) { - if (dev->val[i].w < dev->opt[i].constraint.range->min) - dev->val[i].w = dev->opt[i].constraint.range->min; - if (dev->val[i].w > dev->opt[i].constraint.range->max) - dev->val[i].w = dev->opt[i].constraint.range->max; - } - - if (dev->val[OPT_SCAN_TL_X].w > dev->val[OPT_SCAN_BR_X].w) - SWAP_Word(dev->val[OPT_SCAN_TL_X].w, dev->val[OPT_SCAN_BR_X].w); - if (dev->val[OPT_SCAN_TL_Y].w > dev->val[OPT_SCAN_BR_Y].w) - SWAP_Word(dev->val[OPT_SCAN_TL_Y].w, dev->val[OPT_SCAN_BR_Y].w); - - /* recalculate millimeters to inches */ - dev->win_off_x = SANE_UNFIX(dev->val[OPT_SCAN_TL_X].w) / MM_PER_INCH; - dev->win_off_y = SANE_UNFIX(dev->val[OPT_SCAN_TL_Y].w) / MM_PER_INCH; - - /* calc win size in mm */ - win_width_mm = SANE_UNFIX(dev->val[OPT_SCAN_BR_X].w) - - SANE_UNFIX(dev->val[OPT_SCAN_TL_X].w); - win_len_mm = SANE_UNFIX(dev->val[OPT_SCAN_BR_Y].w) - - SANE_UNFIX(dev->val[OPT_SCAN_TL_Y].w); - /* convert mm to 1200 dpi points */ - dev->win_width = (int)(win_width_mm * PNT_PER_MM); - dev->win_len = (int)(win_len_mm * PNT_PER_MM); - - /* don't scan if window is zero size */ - if (!dev->win_width || !dev->win_len) { - /* "The scan cannot be started with the current set of options." */ - dev->state = SANE_STATUS_INVAL; - return 0; - } + double win_width_mm, win_len_mm; + int i; + int threshold = SANE_UNFIX(dev->val[OPT_THRESHOLD].w); - return 1; -} + dev->resolution = dpi_to_code(dev->val[OPT_RESOLUTION].w); + dev->composition = scan_mode_to_code[string_match_index(scan_modes, dev->val[OPT_MODE].s)]; -static int dev_set_window (struct device *dev) -{ - SANE_Byte cmd[0x19] = { - REQ_CODE_A, REQ_CODE_B, CMD_SET_WINDOW, 0x13, MSG_SCANNING_PARAM - }; + if (dev->composition == MODE_LINEART || + dev->composition == MODE_HALFTONE) { + dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; + } else { + dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; + } + if (threshold < 30) { + dev->val[OPT_THRESHOLD].w = SANE_FIX(30); + } else if (threshold > 70) { + dev->val[OPT_THRESHOLD].w = SANE_FIX(70); + } + threshold = SANE_UNFIX(dev->val[OPT_THRESHOLD].w); + dev->threshold = (threshold - 30) / 10; + dev->val[OPT_THRESHOLD].w = SANE_FIX(dev->threshold * 10 + 30); - if (!fix_window(dev)) - return 0; + dev->doc_source = doc_source_to_code[string_match_index(doc_sources, dev->val[OPT_SOURCE].s)]; + + /* max window len is dependent of document source */ + if (dev->doc_source == DOC_FLATBED || + (dev->doc_source == DOC_AUTO && !dev->doc_loaded)) + dev->max_len = dev->max_len_fb; + else + dev->max_len = dev->max_len_adf; + + /* parameters */ + dev->win_y_range.max = SANE_FIX((double)dev->max_len / PNT_PER_MM); + + /* window sanity checking */ + for (i = OPT_SCAN_TL_X; i <= OPT_SCAN_BR_Y; i++) { + if (dev->val[i].w < dev->opt[i].constraint.range->min) + dev->val[i].w = dev->opt[i].constraint.range->min; + if (dev->val[i].w > dev->opt[i].constraint.range->max) + dev->val[i].w = dev->opt[i].constraint.range->max; + } + + if (dev->val[OPT_SCAN_TL_X].w > dev->val[OPT_SCAN_BR_X].w) + SWAP_Word(dev->val[OPT_SCAN_TL_X].w, dev->val[OPT_SCAN_BR_X].w); + if (dev->val[OPT_SCAN_TL_Y].w > dev->val[OPT_SCAN_BR_Y].w) + SWAP_Word(dev->val[OPT_SCAN_TL_Y].w, dev->val[OPT_SCAN_BR_Y].w); + + /* recalculate millimeters to inches */ + dev->win_off_x = SANE_UNFIX(dev->val[OPT_SCAN_TL_X].w) / MM_PER_INCH; + dev->win_off_y = SANE_UNFIX(dev->val[OPT_SCAN_TL_Y].w) / MM_PER_INCH; + + /* calc win size in mm */ + win_width_mm = SANE_UNFIX(dev->val[OPT_SCAN_BR_X].w) - + SANE_UNFIX(dev->val[OPT_SCAN_TL_X].w); + win_len_mm = SANE_UNFIX(dev->val[OPT_SCAN_BR_Y].w) - + SANE_UNFIX(dev->val[OPT_SCAN_TL_Y].w); + /* convert mm to 1200 dpi points */ + dev->win_width = (int)(win_width_mm * PNT_PER_MM); + dev->win_len = (int)(win_len_mm * PNT_PER_MM); + + /* don't scan if window is zero size */ + if (!dev->win_width || !dev->win_len) { + /* "The scan cannot be started with the current set of options." */ + dev->state = SANE_STATUS_INVAL; + return 0; + } - cmd[0x05] = dev->win_width >> 24; - cmd[0x06] = dev->win_width >> 16; - cmd[0x07] = dev->win_width >> 8; - cmd[0x08] = dev->win_width; - cmd[0x09] = dev->win_len >> 24; - cmd[0x0a] = dev->win_len >> 16; - cmd[0x0b] = dev->win_len >> 8; - cmd[0x0c] = dev->win_len; - cmd[0x0d] = dev->resolution; /* x */ - cmd[0x0e] = dev->resolution; /* y */ - cmd[0x0f] = (SANE_Byte)floor(dev->win_off_x); - cmd[0x10] = (SANE_Byte)((dev->win_off_x - floor(dev->win_off_x)) * 100); - cmd[0x11] = (SANE_Byte)floor(dev->win_off_y); - cmd[0x12] = (SANE_Byte)((dev->win_off_y - floor(dev->win_off_y)) * 100); - cmd[0x13] = dev->composition; - cmd[0x16] = dev->threshold; - cmd[0x17] = dev->doc_source; - - DBG (5, "OFF xi: %02x%02x yi: %02x%02x," - " WIN xp: %02x%02x%02x%02x yp %02x%02x%02x%02x," - " MAX %08x %08x\n", - cmd[0x0f], cmd[0x10], cmd[0x11], cmd[0x12], - cmd[0x05], cmd[0x06], cmd[0x07], cmd[0x08], - cmd[0x09], cmd[0x0a], cmd[0x0b], cmd[0x0c], - dev->max_win_width, dev->max_win_len); - - return dev_command (dev, cmd, 32); + return 1; +} + +static int dev_set_window(struct device *dev) +{ + SANE_Byte cmd[0x19] = { + REQ_CODE_A, REQ_CODE_B, CMD_SET_WINDOW, 0x13, MSG_SCANNING_PARAM + }; + + if (!fix_window(dev)) + return 0; + + cmd[0x05] = dev->win_width >> 24; + cmd[0x06] = dev->win_width >> 16; + cmd[0x07] = dev->win_width >> 8; + cmd[0x08] = dev->win_width; + cmd[0x09] = dev->win_len >> 24; + cmd[0x0a] = dev->win_len >> 16; + cmd[0x0b] = dev->win_len >> 8; + cmd[0x0c] = dev->win_len; + cmd[0x0d] = dev->resolution; /* x */ + cmd[0x0e] = dev->resolution; /* y */ + cmd[0x0f] = (SANE_Byte)floor(dev->win_off_x); + cmd[0x10] = (SANE_Byte)((dev->win_off_x - floor(dev->win_off_x)) * 100); + cmd[0x11] = (SANE_Byte)floor(dev->win_off_y); + cmd[0x12] = (SANE_Byte)((dev->win_off_y - floor(dev->win_off_y)) * 100); + cmd[0x13] = dev->composition; + /* Set to JPEG Lossy Compression, if mode is color (only for supported model)... + * else go with Uncompressed (For backard compatibility with old models )*/ + if (dev->composition == MODE_RGB24) { + if (isSupportedDevice(dev)) { + cmd[0x14] = 0x6; + } + } + cmd[0x16] = dev->threshold; + cmd[0x17] = dev->doc_source; + + DBG(5, "OFF xi: %02x%02x yi: %02x%02x," + " WIN xp: %02x%02x%02x%02x yp %02x%02x%02x%02x," + " MAX %08x %08x\n", + cmd[0x0f], cmd[0x10], cmd[0x11], cmd[0x12], + cmd[0x05], cmd[0x06], cmd[0x07], cmd[0x08], + cmd[0x09], cmd[0x0a], cmd[0x0b], cmd[0x0c], + dev->max_win_width, dev->max_win_len); + + return dev_command(dev, cmd, 32); } static SANE_Status -dev_inquiry (struct device *dev) +dev_inquiry(struct device *dev) { - SANE_Byte *ptr; - SANE_Char *optr, *xptr; - - if (!dev_cmd (dev, CMD_INQUIRY)) - return SANE_STATUS_IO_ERROR; - ptr = dev->res; - if (ptr[3] != MSG_PRODUCT_INFO) { - DBG (1, "%s: illegal INQUIRY response %02x\n", __FUNCTION__, ptr[3]); - return SANE_STATUS_IO_ERROR; - } - - /* parse reported manufacturer/product names */ - dev->sane.vendor = optr = (SANE_Char *) malloc (33); - for (ptr += 4; ptr < &dev->res[0x24] && *ptr && *ptr != ' ';) - *optr++ = *ptr++; - *optr++ = 0; - - for (; ptr < &dev->res[0x24] && (!*ptr || *ptr == ' '); ptr++) - /* skip spaces */; - - dev->sane.model = optr = (SANE_Char *) malloc (33); - xptr = optr; /* is last non space character + 1 */ - for (; ptr < &dev->res[0x24] && *ptr;) { - if (*ptr != ' ') - xptr = optr + 1; - *optr++ = *ptr++; - } - *optr++ = 0; - *xptr = 0; - - DBG (1, "%s: found %s/%s\n", __FUNCTION__, dev->sane.vendor, dev->sane.model); - dev->sane.type = strdup ("multi-function peripheral"); - - dev->resolutions = dev->res[0x37] << 16 | - dev->res[0x24] << 8 | - dev->res[0x25]; - dev->compositions = dev->res[0x27]; - dev->max_win_width = dev->res[0x28] << 24 | - dev->res[0x29] << 16 | - dev->res[0x2a] << 8 | - dev->res[0x2b]; - dev->max_win_len = dev->res[0x2c] << 24 | - dev->res[0x2d] << 16 | - dev->res[0x2e] << 8 | - dev->res[0x2f]; - dev->max_len_adf = dev->res[0x38] << 24 | - dev->res[0x39] << 16 | - dev->res[0x3a] << 8 | - dev->res[0x3b]; - dev->max_len_fb = dev->res[0x3c] << 24 | - dev->res[0x3d] << 16 | - dev->res[0x3e] << 8 | - dev->res[0x3f]; - dev->line_order = dev->res[0x31]; - dev->doc_loaded = (dev->res[0x35] == 0x02) && - (dev->res[0x26] & 0x03); - - init_options(dev); - reset_options(dev); - fix_window(dev); - set_parameters(dev); - resolv_inq_dpi(dev); - - return SANE_STATUS_GOOD; + SANE_Byte *ptr; + SANE_Char *optr, *xptr; + + if (!dev_cmd(dev, CMD_INQUIRY)) + return SANE_STATUS_IO_ERROR; + ptr = dev->res; + if (ptr[3] != MSG_PRODUCT_INFO) { + DBG(1, "%s: illegal INQUIRY response %02x\n", __func__, ptr[3]); + return SANE_STATUS_IO_ERROR; + } + + /* parse reported manufacturer/product names */ + dev->sane.vendor = optr = (SANE_Char *) malloc(33); + for (ptr += 4; ptr < &dev->res[0x24] && *ptr && *ptr != ' ';) + *optr++ = *ptr++; + *optr++ = 0; + + for (; ptr < &dev->res[0x24] && (!*ptr || *ptr == ' '); ptr++) + /* skip spaces */; + + dev->sane.model = optr = (SANE_Char *) malloc(33); + xptr = optr; /* is last non space character + 1 */ + for (; ptr < &dev->res[0x24] && *ptr;) { + if (*ptr != ' ') + xptr = optr + 1; + *optr++ = *ptr++; + } + *optr++ = 0; + *xptr = 0; + + DBG(1, "%s: found %s/%s\n", __func__, dev->sane.vendor, dev->sane.model); + dev->sane.type = strdup("multi-function peripheral"); + + dev->resolutions = dev->res[0x37] << 16 | + dev->res[0x24] << 8 | + dev->res[0x25]; + dev->compositions = dev->res[0x27]; + dev->max_win_width = dev->res[0x28] << 24 | + dev->res[0x29] << 16 | + dev->res[0x2a] << 8 | + dev->res[0x2b]; + dev->max_win_len = dev->res[0x2c] << 24 | + dev->res[0x2d] << 16 | + dev->res[0x2e] << 8 | + dev->res[0x2f]; + dev->max_len_adf = dev->res[0x38] << 24 | + dev->res[0x39] << 16 | + dev->res[0x3a] << 8 | + dev->res[0x3b]; + dev->max_len_fb = dev->res[0x3c] << 24 | + dev->res[0x3d] << 16 | + dev->res[0x3e] << 8 | + dev->res[0x3f]; + dev->line_order = dev->res[0x31]; + dev->compressionTypes = dev->res[0x32]; + dev->doc_loaded = (dev->res[0x35] == 0x02) && + (dev->res[0x26] & 0x03); + + init_options(dev); + reset_options(dev); + fix_window(dev); + set_parameters(dev); + resolv_inq_dpi(dev); + + return SANE_STATUS_GOOD; } const SANE_Option_Descriptor * -sane_get_option_descriptor (SANE_Handle h, SANE_Int opt) +sane_get_option_descriptor(SANE_Handle h, SANE_Int opt) { - struct device *dev = h; + struct device *dev = h; - DBG (3, "%s: %p, %d\n", __FUNCTION__, h, opt); - if (opt >= NUM_OPTIONS || opt < 0) - return NULL; - return &dev->opt[opt]; + DBG(3, "%s: %p, %d\n", __func__, h, opt); + if (opt >= NUM_OPTIONS || opt < 0) + return NULL; + return &dev->opt[opt]; } SANE_Status -sane_control_option (SANE_Handle h, SANE_Int opt, SANE_Action act, - void *val, SANE_Word * info) +sane_control_option(SANE_Handle h, SANE_Int opt, SANE_Action act, + void *val, SANE_Word *info) { - struct device *dev = h; - - DBG (3, "%s: %p, %d, <%d>, %p, %p\n", __FUNCTION__, h, opt, act, val, (void *)info); - if (!dev || opt >= NUM_OPTIONS || opt < 0) - return SANE_STATUS_INVAL; - - if (info) - *info = 0; - - if (act == SANE_ACTION_GET_VALUE) { /* GET */ - if (dev->opt[opt].type == SANE_TYPE_STRING) - strcpy(val, dev->val[opt].s); - else - *(SANE_Word *)val = dev->val[opt].w; - } else if (act == SANE_ACTION_SET_VALUE) { /* SET */ - SANE_Parameters xpara = dev->para; - SANE_Option_Descriptor xopt[NUM_OPTIONS]; - Option_Value xval[NUM_OPTIONS]; - int i; - - if (dev->opt[opt].constraint_type == SANE_CONSTRAINT_STRING_LIST) { - dev->val[opt].s = string_match(dev->opt[opt].constraint.string_list, val); - if (info && strcasecmp(dev->val[opt].s, val)) - *info |= SANE_INFO_INEXACT; - } else if (opt == OPT_RESOLUTION) - dev->val[opt].w = res_dpi_codes[dpi_to_code(*(SANE_Word *)val)]; - else - dev->val[opt].w = *(SANE_Word *)val; - - memcpy(&xopt, &dev->opt, sizeof(xopt)); - memcpy(&xval, &dev->val, sizeof(xval)); - fix_window(dev); - set_parameters(dev); - - /* check for side effects */ - if (info) { - if (memcmp(&xpara, &dev->para, sizeof(xpara))) - *info |= SANE_INFO_RELOAD_PARAMS; - if (memcmp(&xopt, &dev->opt, sizeof(xopt))) - *info |= SANE_INFO_RELOAD_OPTIONS; - for (i = 0; i < NUM_OPTIONS; i++) - if (xval[i].w != dev->val[i].w) { - if (i == opt) - *info |= SANE_INFO_INEXACT; - else - *info |= SANE_INFO_RELOAD_OPTIONS; - } + struct device *dev = h; + + DBG(3, "%s: %p, %d, <%d>, %p, %p\n", __func__, h, opt, act, val, (void *)info); + if (!dev || opt >= NUM_OPTIONS || opt < 0) + return SANE_STATUS_INVAL; + + if (info) + *info = 0; + + if (act == SANE_ACTION_GET_VALUE) { /* GET */ + if (dev->opt[opt].type == SANE_TYPE_STRING) + strcpy(val, dev->val[opt].s); + else + *(SANE_Word *)val = dev->val[opt].w; + } else if (act == SANE_ACTION_SET_VALUE) { /* SET */ + SANE_Parameters xpara = dev->para; + SANE_Option_Descriptor xopt[NUM_OPTIONS]; + Option_Value xval[NUM_OPTIONS]; + int i; + + if (dev->opt[opt].constraint_type == SANE_CONSTRAINT_STRING_LIST) { + dev->val[opt].s = string_match(dev->opt[opt].constraint.string_list, val); + if (info && strcasecmp(dev->val[opt].s, val)) + *info |= SANE_INFO_INEXACT; + } else if (opt == OPT_RESOLUTION) + dev->val[opt].w = res_dpi_codes[dpi_to_code(*(SANE_Word *)val)]; + else + dev->val[opt].w = *(SANE_Word *)val; + + memcpy(&xopt, &dev->opt, sizeof(xopt)); + memcpy(&xval, &dev->val, sizeof(xval)); + fix_window(dev); + set_parameters(dev); + + /* check for side effects */ + if (info) { + if (memcmp(&xpara, &dev->para, sizeof(xpara))) + *info |= SANE_INFO_RELOAD_PARAMS; + if (memcmp(&xopt, &dev->opt, sizeof(xopt))) + *info |= SANE_INFO_RELOAD_OPTIONS; + for (i = 0; i < NUM_OPTIONS; i++) + if (xval[i].w != dev->val[i].w) { + if (i == opt) + *info |= SANE_INFO_INEXACT; + else + *info |= SANE_INFO_RELOAD_OPTIONS; + } + } } - } - DBG (4, "%s: %d, <%d> => %08x, %x\n", __FUNCTION__, opt, act, - val? *(SANE_Word *)val : 0, info? *info : 0); - return SANE_STATUS_GOOD; + DBG(4, "%s: %d, <%d> => %08x, %x\n", __func__, opt, act, + val? *(SANE_Word *)val : 0, info? *info : 0); + return SANE_STATUS_GOOD; } static void -dev_free (struct device *dev) +dev_free(struct device *dev) { - if (!dev) - return; - - if (dev->sane.name) - free (UNCONST(dev->sane.name)); - if (dev->sane.vendor) - free (UNCONST(dev->sane.vendor)); - if (dev->sane.model) - free (UNCONST(dev->sane.model)); - if (dev->sane.type) - free (UNCONST(dev->sane.type)); - if (dev->data) - free(dev->data); - memset (dev, 0, sizeof (*dev)); - free (dev); + if (!dev) + return; + + if (dev->sane.name) + free(UNCONST(dev->sane.name)); + if (dev->sane.vendor) + free(UNCONST(dev->sane.vendor)); + if (dev->sane.model) + free(UNCONST(dev->sane.model)); + if (dev->sane.type) + free(UNCONST(dev->sane.type)); + if (dev->data) + free(dev->data); + if (dev->decData) { + free(dev->decData); + dev->decData = NULL; + } + memset(dev, 0, sizeof(*dev)); + free(dev); } static void -free_devices (void) +free_devices(void) { - int i; - struct device *next; - struct device *dev; - - if (devlist) { - free (devlist); - devlist = NULL; - } - for (i = 0, dev = devices_head; dev; dev = next) { - next = dev->next; - dev_free (dev); - } - devices_head = NULL; + struct device *next; + struct device *dev; + + if (devlist) { + free(devlist); + devlist = NULL; + } + for (dev = devices_head; dev; dev = next) { + next = dev->next; + dev_free(dev); + } + devices_head = NULL; } static transport *tr_from_devname(SANE_String_Const devname) { - if (strncmp("tcp", devname, 3) == 0) - return &available_transports[TRANSPORT_TCP]; - return &available_transports[TRANSPORT_USB]; + if (strncmp("tcp", devname, 3) == 0) + return &available_transports[TRANSPORT_TCP]; + return &available_transports[TRANSPORT_USB]; } static SANE_Status -list_one_device (SANE_String_Const devname) +list_one_device(SANE_String_Const devname) { - struct device *dev; - SANE_Status status; - transport *tr; - - DBG (4, "%s: %s\n", __FUNCTION__, devname); - - for (dev = devices_head; dev; dev = dev->next) { - if (strcmp (dev->sane.name, devname) == 0) - return SANE_STATUS_GOOD; - } - - tr = tr_from_devname(devname); - - dev = calloc (1, sizeof (struct device)); - if (dev == NULL) - return SANE_STATUS_NO_MEM; - - dev->sane.name = strdup (devname); - dev->io = tr; - status = tr->dev_open (dev); - if (status != SANE_STATUS_GOOD) { - dev_free (dev); - return status; - } - -/* status = dev_cmd (dev, CMD_ABORT);*/ - status = dev_inquiry (dev); - tr->dev_close (dev); - if (status != SANE_STATUS_GOOD) { - DBG (1, "%s: dev_inquiry(%s): %s\n", __FUNCTION__, - dev->sane.name, sane_strstatus (status)); - dev_free (dev); - return status; - } - - /* good device, add it to list */ - dev->next = devices_head; - devices_head = dev; - return SANE_STATUS_GOOD; + struct device *dev; + SANE_Status status; + transport *tr; + + DBG(4, "%s: %s\n", __func__, devname); + + for (dev = devices_head; dev; dev = dev->next) { + if (strcmp(dev->sane.name, devname) == 0) + return SANE_STATUS_GOOD; + } + + tr = tr_from_devname(devname); + + dev = calloc(1, sizeof(struct device)); + if (dev == NULL) + return SANE_STATUS_NO_MEM; + + dev->sane.name = strdup(devname); + dev->io = tr; + status = tr->dev_open(dev); + if (status != SANE_STATUS_GOOD) { + dev_free(dev); + return status; + } + + /* status = dev_cmd (dev, CMD_ABORT);*/ + status = dev_inquiry(dev); + tr->dev_close(dev); + if (status != SANE_STATUS_GOOD) { + DBG(1, "%s: dev_inquiry(%s): %s\n", __func__, + dev->sane.name, sane_strstatus(status)); + dev_free(dev); + return status; + } + + /* good device, add it to list */ + dev->next = devices_head; + devices_head = dev; + return SANE_STATUS_GOOD; } /* SANE API ignores return code of this callback */ static SANE_Status -list_conf_devices (UNUSED (SANEI_Config * config), const char *devname) +list_conf_devices(UNUSED(SANEI_Config *config), const char *devname) { - return tr_from_devname(devname)->configure_device(devname, list_one_device); + return tr_from_devname(devname)->configure_device(devname, list_one_device); } SANE_Status -sane_init (SANE_Int * version_code, SANE_Auth_Callback cb) +sane_init(SANE_Int *version_code, SANE_Auth_Callback cb) { - DBG_INIT (); - DBG (2, "sane_init: Xerox backend (build %d), version %s null, authorize %s null\n", BACKEND_BUILD, - (version_code) ? "!=" : "==", (cb) ? "!=" : "=="); + DBG_INIT(); + DBG(2, "sane_init: Xerox backend (build %d), version %s null, authorize %s null\n", BACKEND_BUILD, + (version_code) ? "!=" : "==", (cb) ? "!=" : "=="); - if (version_code) - *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, BACKEND_BUILD); + if (version_code) + *version_code = SANE_VERSION_CODE(V_MAJOR, V_MINOR, BACKEND_BUILD); - sanei_usb_init (); - return SANE_STATUS_GOOD; + sanei_usb_init(); + return SANE_STATUS_GOOD; } void -sane_exit (void) +sane_exit(void) { - struct device *dev; + struct device *dev; + + for (dev = devices_head; dev; dev = dev->next) + if (dev->dn != -1) + sane_close(dev); /* implies flush */ - for (dev = devices_head; dev; dev = dev->next) - if (dev->dn != -1) - sane_close(dev); /* implies flush */ - - free_devices (); + free_devices(); } SANE_Status -sane_get_devices (const SANE_Device *** device_list, SANE_Bool local) +sane_get_devices(const SANE_Device *** device_list, SANE_Bool local) { - SANEI_Config config; - struct device *dev; - int dev_count; - int i; + SANEI_Config config; + struct device *dev; + int dev_count; + int i; - DBG (3, "%s: %p, %d\n", __FUNCTION__, (const void *)device_list, local); + DBG(3, "%s: %p, %d\n", __func__, (const void *)device_list, local); - if (devlist) { - if (device_list) - *device_list = devlist; - return SANE_STATUS_GOOD; - } + if (devlist) { + if (device_list) + *device_list = devlist; + return SANE_STATUS_GOOD; + } - free_devices (); + free_devices(); - config.count = 0; - config.descriptors = NULL; - config.values = NULL; - sanei_configure_attach (XEROX_CONFIG_FILE, &config, list_conf_devices); + config.count = 0; + config.descriptors = NULL; + config.values = NULL; + sanei_configure_attach(XEROX_CONFIG_FILE, &config, list_conf_devices); - for (dev_count = 0, dev = devices_head; dev; dev = dev->next) - dev_count++; + for (dev_count = 0, dev = devices_head; dev; dev = dev->next) + dev_count++; - devlist = malloc ((dev_count + 1) * sizeof (*devlist)); - if (!devlist) - { - DBG (1, "%s: malloc: no memory\n", __FUNCTION__); - return SANE_STATUS_NO_MEM; + devlist = malloc((dev_count + 1) * sizeof(*devlist)); + if (!devlist) { + DBG(1, "%s: malloc: no memory\n", __func__); + return SANE_STATUS_NO_MEM; } - for (i = 0, dev = devices_head; dev; dev = dev->next) - devlist[i++] = &dev->sane; - devlist[i++] = NULL; + for (i = 0, dev = devices_head; dev; dev = dev->next) + devlist[i++] = &dev->sane; + devlist[i++] = NULL; - if (device_list) - *device_list = devlist; - return SANE_STATUS_GOOD; + if (device_list) + *device_list = devlist; + return SANE_STATUS_GOOD; } void -sane_close (SANE_Handle h) +sane_close(SANE_Handle h) { - struct device *dev = h; + struct device *dev = h; - if (!dev) - return; + if (!dev) + return; - DBG (3, "%s: %p (%s)\n", __FUNCTION__, (void *)dev, dev->sane.name); - dev->io->dev_close(dev); + DBG(3, "%s: %p (%s)\n", __func__, (void *)dev, dev->sane.name); + dev->io->dev_close(dev); } SANE_Status -sane_open (SANE_String_Const name, SANE_Handle * h) +sane_open(SANE_String_Const name, SANE_Handle *h) { - struct device *dev; - - DBG (3, "%s: '%s'\n", __FUNCTION__, name); - - if (!devlist) - sane_get_devices (NULL, SANE_TRUE); - - if (!name || !*name) { - /* special case of empty name: open first available device */ - for (dev = devices_head; dev; dev = dev->next) { - if (dev->dn != -1) { - if (sane_open (dev->sane.name, h) == SANE_STATUS_GOOD) - return SANE_STATUS_GOOD; - } + struct device *dev; + + DBG(3, "%s: '%s'\n", __func__, name); + + if (!devlist) + sane_get_devices(NULL, SANE_TRUE); + + if (!name || !*name) { + /* special case of empty name: open first available device */ + for (dev = devices_head; dev; dev = dev->next) { + if (dev->dn != -1) { + if (sane_open(dev->sane.name, h) == SANE_STATUS_GOOD) + return SANE_STATUS_GOOD; + } + } + } else { + for (dev = devices_head; dev; dev = dev->next) { + if (strcmp(name, dev->sane.name) == 0) { + *h = dev; + return dev->io->dev_open(dev); + } + } } - } else { - for (dev = devices_head; dev; dev = dev->next) { - if (strcmp(name, dev->sane.name) == 0) { - *h = dev; - return dev->io->dev_open(dev); - } - } - } - return SANE_STATUS_INVAL; + return SANE_STATUS_INVAL; } SANE_Status -sane_get_parameters (SANE_Handle h, SANE_Parameters * para) +sane_get_parameters(SANE_Handle h, SANE_Parameters *para) { - struct device *dev = h; + struct device *dev = h; - DBG (3, "%s: %p, %p\n", __FUNCTION__, h, (void *)para); - if (!para) - return SANE_STATUS_INVAL; + DBG(3, "%s: %p, %p\n", __func__, h, (void *)para); + if (!para) + return SANE_STATUS_INVAL; - *para = dev->para; - return SANE_STATUS_GOOD; + *para = dev->para; + return SANE_STATUS_GOOD; } /* check if image data is ready, and wait if not */ /* 1: image is acquired, 0: error or non_blocking mode */ static int dev_acquire(struct device *dev) { - if (!dev_cmd_wait(dev, CMD_READ)) - return dev->state; - - dev->state = SANE_STATUS_GOOD; - dev->vertical = dev->res[0x08] << 8 | dev->res[0x09]; - dev->horizontal = dev->res[0x0a] << 8 | dev->res[0x0b]; - dev->blocklen = dev->res[4] << 24 | - dev->res[5] << 16 | - dev->res[6] << 8 | - dev->res[7]; - dev->final_block = (dev->res[3] == MSG_END_BLOCK)? 1 : 0; - - dev->pixels_per_line = dev->horizontal; - dev->bytes_per_line = dev->horizontal; - - if (dev->composition == MODE_RGB24) - dev->bytes_per_line *= 3; - else if (dev->composition == MODE_LINEART || - dev->composition == MODE_HALFTONE) - dev->pixels_per_line *= 8; - - DBG (4, "acquiring, size per band v: %d, h: %d, %sblock: %d, slack: %d\n", - dev->vertical, dev->horizontal, dev->final_block? "last " : "", - dev->blocklen, dev->blocklen - (dev->vertical * dev->bytes_per_line)); - - if (dev->bytes_per_line > DATASIZE) { - DBG (1, "%s: unsupported line size: %d bytes > %d\n", - __FUNCTION__, dev->bytes_per_line, DATASIZE); - return ret_cancel(dev, SANE_STATUS_NO_MEM); - } - - dev->reading = 0; /* need to issue READ_IMAGE */ - - dev->dataindex = 0; - dev->datalen = 0; - dev->dataoff = 0; - - return 1; + if (!dev_cmd_wait(dev, CMD_READ)) + return dev->state; + + dev->state = SANE_STATUS_GOOD; + dev->vertical = dev->res[0x08] << 8 | dev->res[0x09]; + dev->horizontal = dev->res[0x0a] << 8 | dev->res[0x0b]; + dev->blocklen = dev->res[4] << 24 | + dev->res[5] << 16 | + dev->res[6] << 8 | + dev->res[7]; + dev->final_block = (dev->res[3] == MSG_END_BLOCK)? 1 : 0; + + dev->pixels_per_line = dev->horizontal; + dev->bytes_per_line = dev->horizontal; + + if (dev->composition == MODE_RGB24) + dev->bytes_per_line *= 3; + else if (dev->composition == MODE_LINEART || + dev->composition == MODE_HALFTONE) + dev->pixels_per_line *= 8; + + DBG(4, "acquiring, size per band v: %d, h: %d, %sblock: %d, slack: %d\n", + dev->vertical, dev->horizontal, dev->final_block? "last " : "", + dev->blocklen, dev->blocklen - (dev->vertical * dev->bytes_per_line)); + + if (dev->bytes_per_line > DATASIZE) { + DBG(1, "%s: unsupported line size: %d bytes > %d\n", + __func__, dev->bytes_per_line, DATASIZE); + return ret_cancel(dev, SANE_STATUS_NO_MEM); + } + + dev->reading = 0; /* need to issue READ_IMAGE */ + + dev->dataindex = 0; + dev->datalen = 0; + dev->dataoff = 0; + + return 1; } static int fill_slack(struct device *dev, SANE_Byte *buf, int maxlen) { - const int slack = dev->total_img_size - dev->total_out_size; - const int havelen = MIN(slack, maxlen); - int j; - - if (havelen <= 0) - return 0; - for (j = 0; j < havelen; j++) - buf[j] = 255; - return havelen; + const int slack = dev->total_img_size - dev->total_out_size; + const int havelen = MIN(slack, maxlen); + int j; + + if (havelen <= 0) + return 0; + for (j = 0; j < havelen; j++) + buf[j] = 255; + return havelen; } static int copy_plain_trim(struct device *dev, SANE_Byte *buf, int maxlen, int *olenp) { - int j; - const int linesize = dev->bytes_per_line; - int k = dev->dataindex; - *olenp = 0; - for (j = 0; j < dev->datalen && *olenp < maxlen; j++, k++) { - const int x = k % linesize; - const int y = k / linesize; - if (y >= dev->vertical) - break; /* slack */ - if (x < dev->para.bytes_per_line && - (y + dev->y_off) < dev->para.lines) { - *buf++ = dev->data[(dev->dataoff + j) & DATAMASK]; - (*olenp)++; + int j; + const int linesize = dev->bytes_per_line; + int k = dev->dataindex; + *olenp = 0; + for (j = 0; j < dev->datalen && *olenp < maxlen; j++, k++) { + const int x = k % linesize; + const int y = k / linesize; + if (y >= dev->vertical) + break; /* slack */ + if (x < dev->para.bytes_per_line && + (y + dev->y_off) < dev->para.lines) { + *buf++ = dev->data[(dev->dataoff + j) & DATAMASK]; + (*olenp)++; + } } - } - dev->dataindex = k; - return j; + dev->dataindex = k; + return j; } /* return: how much data could be freed from cyclic buffer */ /* convert from RRGGBB to RGBRGB */ -static int copy_mix_bands_trim(struct device *dev, SANE_Byte *buf, int maxlen, int *olenp) { - int j; +static int copy_mix_bands_trim(struct device *dev, SANE_Byte *buf, int maxlen, int *olenp) +{ + int j; - const int linesize = dev->bytes_per_line; /* caching real line size */ + const int linesize = dev->bytes_per_line; /* caching real line size */ - /* line number of the head of input buffer, - * input buffer is always aligned to whole line */ - const int y_off = dev->dataindex / linesize; + /* line number of the head of input buffer, + * input buffer is always aligned to whole line */ + const int y_off = dev->dataindex / linesize; - int k = dev->dataindex; /* caching current index of input buffer */ + int k = dev->dataindex; /* caching current index of input buffer */ - /* can only copy as much as full lines we have */ - int havelen = dev->datalen / linesize * linesize - k % linesize; + /* can only copy as much as full lines we have */ + int havelen = dev->datalen / linesize * linesize - k % linesize; - const int bands = 3; - *olenp = 0; + const int bands = 3; + *olenp = 0; - /* while we have data && they can receive */ - for (j = 0; j < havelen && *olenp < maxlen; j++, k++) { - const int band = (k % bands) * dev->horizontal; - const int x = k % linesize / bands; - const int y = k / linesize - y_off; /* y relative to buffer head */ - const int y_rly = y + y_off + dev->y_off; /* global y */ + /* while we have data && they can receive */ + for (j = 0; j < havelen && *olenp < maxlen; j++, k++) { + const int band = (k % bands) * dev->horizontal; + const int x = k % linesize / bands; + const int y = k / linesize - y_off; /* y relative to buffer head */ + const int y_rly = y + y_off + dev->y_off; /* global y */ - if (x < dev->para.pixels_per_line && - y_rly < dev->para.lines) { - *buf++ = dev->data[(dev->dataoff + band + x + y * linesize) & DATAMASK]; - (*olenp)++; + if (x < dev->para.pixels_per_line && + y_rly < dev->para.lines) { + *buf++ = dev->data[(dev->dataoff + band + x + y * linesize) & DATAMASK]; + (*olenp)++; + } } - } - dev->dataindex = k; + dev->dataindex = k; - /* how much full lines are finished */ - return (k / linesize - y_off) * linesize; + /* how much full lines are finished */ + return (k / linesize - y_off) * linesize; } SANE_Status -sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * lenp) +sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *lenp) { - SANE_Status status; - struct device *dev = h; + SANE_Status status; + struct device *dev = h; + + DBG(3, "%s: %p, %p, %d, %p\n", __func__, h, buf, maxlen, (void *)lenp); + + if (lenp) + *lenp = 0; + if (!dev) + return SANE_STATUS_INVAL; + + if (!dev->scanning) + return SANE_STATUS_EOF; + + /* if there is no data to read or output from buffer */ + if (!dev->blocklen && dev->datalen <= PADDING_SIZE) { + + /* copying uncompressed data */ + if (dev->composition == MODE_RGB24 && + isSupportedDevice(dev) && + dev->decDataSize > 0) { + int diff = dev->total_img_size - dev->total_out_size; + int bufLen = (diff < maxlen) ? diff : maxlen; + if (0 < diff && + 0 < copy_decompress_data(dev, buf, bufLen, lenp)) { + dev->total_out_size += *lenp; + return SANE_STATUS_GOOD; + } + } + + /* and we don't need to acquire next block */ + if (dev->final_block) { + int slack = dev->total_img_size - dev->total_out_size; + + /* but we may need to fill slack */ + if (buf && lenp && slack > 0) { + *lenp = fill_slack(dev, buf, maxlen); + dev->total_out_size += *lenp; + DBG(9, "<> slack: %d, filled: %d, maxlen %d\n", + slack, *lenp, maxlen); + return SANE_STATUS_GOOD; + } else if (slack < 0) { + /* this will never happen */ + DBG(1, "image overflow %d bytes\n", dev->total_img_size - dev->total_out_size); + } + if (isSupportedDevice(dev) && + dev->composition == MODE_RGB24) { + remove(encTmpFileName); + } + /* that's all */ + dev_stop(dev); + return SANE_STATUS_EOF; + } + + /* queue next image block */ + if (!dev_acquire(dev)) + return dev->state; + } + + if (!dev->reading) { + if (cancelled(dev)) + return dev->state; + DBG(5, "READ_IMAGE\n"); + if (!dev_cmd(dev, CMD_READ_IMAGE)) + return SANE_STATUS_IO_ERROR; + dev->reading++; + dev->ulines += dev->vertical; + dev->y_off = dev->ulines - dev->vertical; + dev->total_data_size += dev->blocklen; + dev->blocks++; + } - DBG (3, "%s: %p, %p, %d, %p\n", __FUNCTION__, h, buf, maxlen, (void *)lenp); + do { + size_t datalen; + int clrlen; /* cleared lines len */ + int olen; /* output len */ + + /* read as much data into the buffer */ + datalen = DATAROOM(dev) & USB_BLOCK_MASK; + while (datalen && dev->blocklen) { + SANE_Byte *rbuf = dev->data + DATATAIL(dev); + + DBG(9, "<> request len: %lu, [%d, %d; %d]\n", + (u_long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen); + if ((status = dev->io->dev_request(dev, NULL, 0, rbuf, &datalen)) != + SANE_STATUS_GOOD) + return status; + dev->datalen += datalen; + dev->blocklen -= datalen; + DBG(9, "<> got %lu, [%d, %d; %d]\n", + (u_long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen); + if (dev->blocklen < 0) + return ret_cancel(dev, SANE_STATUS_IO_ERROR); + + datalen = DATAROOM(dev) & USB_BLOCK_MASK; + } + + if (buf && lenp) { /* read mode */ + /* copy will do minimal of valid data */ + if (dev->para.format == SANE_FRAME_RGB && dev->line_order) { + if (isSupportedDevice(dev)) { + clrlen = dump_to_tmp_file(dev); + /* decompress after reading entire block data*/ + if (0 == dev->blocklen) { + decompress_tempfile(dev); + } + copy_decompress_data(dev, buf, maxlen, &olen); + } else { + clrlen = copy_mix_bands_trim(dev, buf, maxlen, &olen); + } + } else + clrlen = copy_plain_trim(dev, buf, maxlen, &olen); + + dev->datalen -= clrlen; + dev->dataoff = (dev->dataoff + clrlen) & DATAMASK; + buf += olen; + maxlen -= olen; + *lenp += olen; + dev->total_out_size += olen; + + DBG(9, "<> olen: %d, clrlen: %d, blocklen: %d/%d, maxlen %d (%d %d %d)\n", + olen, clrlen, dev->blocklen, dev->datalen, maxlen, + dev->dataindex / dev->bytes_per_line + dev->y_off, + dev->y_off, dev->para.lines); + + /* slack beyond last line */ + if (dev->dataindex / dev->bytes_per_line + dev->y_off >= dev->para.lines) { + dev->datalen = 0; + dev->dataoff = 0; + } + + if (!clrlen || maxlen <= 0) + break; + } else { /* flush mode */ + dev->datalen = 0; + dev->dataoff = 0; + } + + } while (dev->blocklen); + + if (lenp) + DBG(9, " ==> %d\n", *lenp); - if (lenp) - *lenp = 0; - if (!dev) - return SANE_STATUS_INVAL; + return SANE_STATUS_GOOD; +} - if (!dev->scanning) - return SANE_STATUS_EOF; - - /* if there is no data to read or output from buffer */ - if (!dev->blocklen && dev->datalen <= PADDING_SIZE) { - - /* and we don't need to acquire next block */ - if (dev->final_block) { - int slack = dev->total_img_size - dev->total_out_size; - - /* but we may need to fill slack */ - if (buf && lenp && slack > 0) { - *lenp = fill_slack(dev, buf, maxlen); - dev->total_out_size += *lenp; - DBG (9, "<> slack: %d, filled: %d, maxlen %d\n", - slack, *lenp, maxlen); - return SANE_STATUS_GOOD; - } else if (slack < 0) { - /* this will never happen */ - DBG(1, "image overflow %d bytes\n", dev->total_img_size - dev->total_out_size); - } - - /* that's all */ - dev_stop(dev); - return SANE_STATUS_EOF; +SANE_Status +sane_start(SANE_Handle h) +{ + struct device *dev = h; + + DBG(3, "%s: %p\n", __func__, h); + + dev->cancel = 0; + dev->scanning = 0; + dev->total_img_size = 0; + dev->total_out_size = 0; + dev->total_data_size = 0; + dev->blocks = 0; + + if (!dev->reserved) { + if (!dev_cmd_wait(dev, CMD_RESERVE_UNIT)) + return dev->state; + dev->reserved++; } - /* queue next image block */ + if (!dev_set_window(dev) || + (dev->state && dev->state != SANE_STATUS_DEVICE_BUSY)) + return dev_stop(dev); + + if (!dev_cmd_wait(dev, CMD_OBJECT_POSITION)) + return dev_stop(dev); + + if (!dev_cmd(dev, CMD_READ) || + (dev->state && dev->state != SANE_STATUS_DEVICE_BUSY)) + return dev_stop(dev); + + dev->scanning = 1; + dev->final_block = 0; + dev->blocklen = 0; + dev->pixels_per_line = 0; + dev->bytes_per_line = 0; + dev->ulines = 0; + + set_parameters(dev); + + if (!dev->data && !(dev->data = malloc(DATASIZE))) + return ret_cancel(dev, SANE_STATUS_NO_MEM); + + if (!dev->decData && !(dev->decData = malloc(POST_DATASIZE))) + return ret_cancel(dev, SANE_STATUS_NO_MEM); + if (!dev_acquire(dev)) - return dev->state; - } - - if (!dev->reading) { - if (cancelled(dev)) - return dev->state; - DBG (5, "READ_IMAGE\n"); - if (!dev_cmd(dev, CMD_READ_IMAGE)) - return SANE_STATUS_IO_ERROR; - dev->reading++; - dev->ulines += dev->vertical; - dev->y_off = dev->ulines - dev->vertical; - dev->total_data_size += dev->blocklen; - dev->blocks++; - } - - do { - size_t datalen; - int clrlen; /* cleared lines len */ - int olen; /* output len */ - - /* read as much data into the buffer */ - datalen = DATAROOM(dev) & USB_BLOCK_MASK; - while (datalen && dev->blocklen) { - SANE_Byte *rbuf = dev->data + DATATAIL(dev); - - DBG (9, "<> request len: %lu, [%d, %d; %d]\n", - (u_long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen); - if ((status = dev->io->dev_request(dev, NULL, 0, rbuf, &datalen)) != - SANE_STATUS_GOOD) - return status; - dev->datalen += datalen; - dev->blocklen -= datalen; - DBG (9, "<> got %lu, [%d, %d; %d]\n", - (u_long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen); - if (dev->blocklen < 0) - return ret_cancel(dev, SANE_STATUS_IO_ERROR); - - datalen = DATAROOM(dev) & USB_BLOCK_MASK; - } + return dev->state; - if (buf && lenp) { /* read mode */ - /* copy will do minimal of valid data */ - if (dev->para.format == SANE_FRAME_RGB && dev->line_order) - clrlen = copy_mix_bands_trim(dev, buf, maxlen, &olen); - else - clrlen = copy_plain_trim(dev, buf, maxlen, &olen); - - dev->datalen -= clrlen; - dev->dataoff = (dev->dataoff + clrlen) & DATAMASK; - buf += olen; - maxlen -= olen; - *lenp += olen; - dev->total_out_size += olen; - - DBG (9, "<> olen: %d, clrlen: %d, blocklen: %d/%d, maxlen %d (%d %d %d)\n", - olen, clrlen, dev->blocklen, dev->datalen, maxlen, - dev->dataindex / dev->bytes_per_line + dev->y_off, - dev->y_off, dev->para.lines); - - /* slack beyond last line */ - if (dev->dataindex / dev->bytes_per_line + dev->y_off >= dev->para.lines) { - dev->datalen = 0; - dev->dataoff = 0; - } - - if (!clrlen || maxlen <= 0) - break; - } else { /* flush mode */ - dev->datalen = 0; - dev->dataoff = 0; + /* make sure to have dev->para <= of real size */ + if (dev->para.pixels_per_line > dev->pixels_per_line) { + dev->para.pixels_per_line = dev->pixels_per_line; + dev->para.bytes_per_line = dev->pixels_per_line; } - } while (dev->blocklen); - - if (lenp) - DBG (9, " ==> %d\n", *lenp); + if (dev->composition == MODE_RGB24) + dev->para.bytes_per_line = dev->para.pixels_per_line * 3; + else if (dev->composition == MODE_LINEART || + dev->composition == MODE_HALFTONE) { + dev->para.bytes_per_line = (dev->para.pixels_per_line + 7) / 8; + dev->para.pixels_per_line = dev->para.bytes_per_line * 8; + } else { + dev->para.bytes_per_line = dev->para.pixels_per_line; + } - return SANE_STATUS_GOOD; -} + dev->total_img_size = dev->para.bytes_per_line * dev->para.lines; -SANE_Status -sane_start (SANE_Handle h) -{ - struct device *dev = h; - - DBG (3, "%s: %p\n", __FUNCTION__, h); - - dev->cancel = 0; - dev->scanning = 0; - dev->total_img_size = 0; - dev->total_out_size = 0; - dev->total_data_size = 0; - dev->blocks = 0; - - if (!dev->reserved) { - if (!dev_cmd_wait(dev, CMD_RESERVE_UNIT)) - return dev->state; - dev->reserved++; - } - - if (!dev_set_window(dev) || - (dev->state && dev->state != SANE_STATUS_DEVICE_BUSY)) - return dev_stop(dev); - - if (!dev_cmd_wait(dev, CMD_OBJECT_POSITION)) - return dev_stop(dev); - - if (!dev_cmd(dev, CMD_READ) || - (dev->state && dev->state != SANE_STATUS_DEVICE_BUSY)) - return dev_stop(dev); - - dev->scanning = 1; - dev->final_block = 0; - dev->blocklen = 0; - dev->pixels_per_line = 0; - dev->bytes_per_line = 0; - dev->ulines = 0; - - set_parameters(dev); - - if (!dev->data && !(dev->data = malloc(DATASIZE))) - return ret_cancel(dev, SANE_STATUS_NO_MEM); - - if (!dev_acquire(dev)) - return dev->state; - - /* make sure to have dev->para <= of real size */ - if (dev->para.pixels_per_line > dev->pixels_per_line) { - dev->para.pixels_per_line = dev->pixels_per_line; - dev->para.bytes_per_line = dev->pixels_per_line; - } - - if (dev->composition == MODE_RGB24) - dev->para.bytes_per_line = dev->para.pixels_per_line * 3; - else if (dev->composition == MODE_LINEART || - dev->composition == MODE_HALFTONE) { - dev->para.bytes_per_line = (dev->para.pixels_per_line + 7) / 8; - dev->para.pixels_per_line = dev->para.bytes_per_line * 8; - } else { - dev->para.bytes_per_line = dev->para.pixels_per_line; - } + if (isSupportedDevice(dev) && + dev->composition == MODE_RGB24) { + int fd; + remove(encTmpFileName); - dev->total_img_size = dev->para.bytes_per_line * dev->para.lines; + /* Precreate temporary file in exclusive mode. */ + fd = open(encTmpFileName, O_CREAT|O_EXCL, 0600); + if (fd == -1) { + DBG(3, "%s: %p, can't create temporary file %s: %s\n", __func__, + (void *)dev, encTmpFileName, strerror(errno)); + return ret_cancel(dev, SANE_STATUS_ACCESS_DENIED); + } + close(fd); + } + dev->currentDecDataIndex = 0; - return SANE_STATUS_GOOD; + return SANE_STATUS_GOOD; } -SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking) +SANE_Status sane_set_io_mode(SANE_Handle h, SANE_Bool non_blocking) { - struct device *dev = h; + struct device *dev = h; - DBG (3, "%s: %p, %d\n", __FUNCTION__, h, non_blocking); + DBG(3, "%s: %p, %d\n", __func__, h, non_blocking); - if (non_blocking) - return SANE_STATUS_UNSUPPORTED; + if (non_blocking) + return SANE_STATUS_UNSUPPORTED; - dev->non_blocking = non_blocking; - return SANE_STATUS_GOOD; + dev->non_blocking = non_blocking; + return SANE_STATUS_GOOD; } -SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fdp) +SANE_Status sane_get_select_fd(SANE_Handle h, SANE_Int *fdp) { - DBG (3, "%s: %p, %p\n", __FUNCTION__, h, (void *)fdp); - /* supporting of this will require thread creation */ - return SANE_STATUS_UNSUPPORTED; + DBG(3, "%s: %p, %p\n", __func__, h, (void *)fdp); + /* supporting of this will require thread creation */ + return SANE_STATUS_UNSUPPORTED; } -void sane_cancel (SANE_Handle h) +void sane_cancel(SANE_Handle h) { - struct device *dev = h; + struct device *dev = h; - DBG (3, "%s: %p\n", __FUNCTION__, h); - dev->cancel = 1; + DBG(3, "%s: %p\n", __func__, h); + dev->cancel = 1; } /* xerox_mfp.c */ diff --git a/backend/xerox_mfp.conf.in b/backend/xerox_mfp.conf.in index e0f78ea..b17c7d7 100644 --- a/backend/xerox_mfp.conf.in +++ b/backend/xerox_mfp.conf.in @@ -5,6 +5,24 @@ ### Samsung Models ### ###################### +#Samsung X4300 Series +usb 0x04e8 0x3324 + +#Samsung K4350 Series +usb 0x04e8 0x3325 + +#Samsung X7600 Series +usb 0x04e8 0x3326 + +#Samsung K7600 Series +usb 0x04e8 0x3327 + +#Samsung K703 Series +usb 0x04e8 0x3331 + +#Samsung X703 Series +usb 0x04e8 0x3332 + #Samsung SCX-4x16 Series usb 0x04e8 0x3409 @@ -178,6 +196,24 @@ usb 0x04e8 0x3466 #Samsung C460 Series usb 0x04e8 0x3468 +#Samsung M458x Series +usb 0x04e8 0x346f + +#Samsung M4370 5370 Series +usb 0x04e8 0x3471 + +#Samsung X401 Series +usb 0x04e8 0x3477 + +#Samsung K401 Series +usb 0x04e8 0x3478 + +#Samsung K3250 Series +usb 0x04e8 0x3481 + +#Samsung X3220 Series +usb 0x04e8 0x3482 + #################### ### Xerox Models ### #################### diff --git a/backend/xerox_mfp.h b/backend/xerox_mfp.h index 500dd26..3d93f06 100644 --- a/backend/xerox_mfp.h +++ b/backend/xerox_mfp.h @@ -1,9 +1,12 @@ /* - * SANE backend for Xerox Phaser 3200MFP - * Copyright 2008 ABC + * SANE backend for Xerox Phaser 3200MFP et al. + * Copyright 2008-2016 ABC * - * Network scanners support - * Copyright 2010 Alexander Kuznetsov + * Network Scanners Support + * Copyright 2010 Alexander Kuznetsov + * + * Color scanning on Samsung M2870 model and Xerox Cognac 3215 & 3225 + * models by Laxmeesh Onkar Markod * * This program is licensed under GPL + SANE exception. * More info at http://www.sane-project.org/license.html @@ -29,130 +32,136 @@ #define SWAP_Word(x, y) { SANE_Word z = x; x = y; y = z; } enum options { - OPT_NUMOPTIONS, - OPT_GROUP_STD, - OPT_RESOLUTION, /* dpi*/ - OPT_MODE, /* color */ - OPT_THRESHOLD, /* brightness */ - OPT_SOURCE, /* affects max window size */ - OPT_GROUP_GEO, - OPT_SCAN_TL_X, /* for (OPT_SCAN_TL_X to OPT_SCAN_BR_Y) */ - OPT_SCAN_TL_Y, - OPT_SCAN_BR_X, - OPT_SCAN_BR_Y, - NUM_OPTIONS + OPT_NUMOPTIONS, + OPT_GROUP_STD, + OPT_RESOLUTION, /* dpi*/ + OPT_MODE, /* color */ + OPT_THRESHOLD, /* brightness */ + OPT_SOURCE, /* affects max window size */ + OPT_GROUP_GEO, + OPT_SCAN_TL_X, /* for (OPT_SCAN_TL_X to OPT_SCAN_BR_Y) */ + OPT_SCAN_TL_Y, + OPT_SCAN_BR_X, + OPT_SCAN_BR_Y, + NUM_OPTIONS }; typedef struct transport transport; struct device { - struct device *next; - SANE_Device sane; - int dn; /* usb file descriptor */ - SANE_Byte res[1024]; /* buffer for responses */ - size_t reslen; /* response len */ - SANE_Option_Descriptor opt[NUM_OPTIONS]; - Option_Value val[NUM_OPTIONS]; - SANE_Parameters para; - SANE_Bool non_blocking; - int scanning; /* scanning is started */ - int cancel; /* cancel flag */ - int state; /* current state */ - int reserved; /* CMD_RESERVE_UNIT */ - int reading; /* READ_IMAGE is sent */ - - SANE_Byte *data; /* postprocessing cyclic buffer 64k */ - int datalen; /* how data in buffer */ - int dataoff; /* offset of data */ - int dataindex; /* sequental number */ + struct device *next; + SANE_Device sane; + int dn; /* usb file descriptor */ + SANE_Byte res[1024]; /* buffer for responses */ + size_t reslen; /* response len */ + SANE_Option_Descriptor opt[NUM_OPTIONS]; + Option_Value val[NUM_OPTIONS]; + SANE_Parameters para; + SANE_Bool non_blocking; + int scanning; /* scanning is started */ + int cancel; /* cancel flag */ + int state; /* current state */ + int reserved; /* CMD_RESERVE_UNIT */ + int reading; /* READ_IMAGE is sent */ + + SANE_Byte *data; /* postprocessing cyclic buffer 64k */ + int datalen; /* how data in buffer */ + int dataoff; /* offset of data */ + int dataindex; /* sequental number */ #define DATAMASK 0xffff /* mask of data buffer */ #define DATASIZE (DATAMASK + 1) /* size of data buffer */ - /* 64K will be enough to hold whole line of 2400 dpi of 23cm */ + /* 64K will be enough to hold whole line of 2400 dpi of 23cm */ #define DATATAIL(dev) ((dev->dataoff + dev->datalen) & DATAMASK) #define DATAROOM(dev) dataroom(dev) - /* data from CMD_INQUIRY: */ - int resolutions; /* supported resolution bitmask */ - int compositions; /* supported image compositions bitmask */ - int max_len; /* effective max len for current doc source */ - int max_win_width; - int max_win_len; - int max_len_adf; - int max_len_fb; - int line_order; /* if need post processing */ - SANE_Word dpi_list[30]; /* allowed resolutions */ - int doc_loaded; - - SANE_Range win_x_range; - SANE_Range win_y_range; - - /* CMD_SET_WINDOW parameters we set: */ - int win_width; /* in 1200dpi points */ - int win_len; - double win_off_x; /* in inches (byte.byte) */ - double win_off_y; - int resolution; /* dpi indexed values */ - int composition; /* MODE_ */ - int doc_source; /* document source */ - int threshold; /* brightness */ - - /* CMD_READ data. It is per block only, image could be in many blocks */ - int blocklen; /* image data block len (padding incl.) */ - int vertical; /* lines in block (padded) */ - int horizontal; /* b/w: bytes, gray/color: pixels (padded) */ - int final_block; - int pixels_per_line; - int bytes_per_line; - int ulines; /* up to this block including */ - int y_off; /* up to this block excluding*/ - int blocks; - - /* stat */ - int total_img_size; /* predicted image size */ - int total_out_size; /* total we sent to user */ - int total_data_size; /* total of what scanner sent us */ - - /* transport to use */ - transport *io; +#define POST_DATASIZE 0xFFFFFF + SANE_Byte *decData; + int decDataSize; + int currentDecDataIndex; + /* data from CMD_INQUIRY: */ + int resolutions; /* supported resolution bitmask */ + int compositions; /* supported image compositions bitmask */ + int max_len; /* effective max len for current doc source */ + int max_win_width; + int max_win_len; + int max_len_adf; + int max_len_fb; + int line_order; /* if need post processing */ + SANE_Word dpi_list[30]; /* allowed resolutions */ + int doc_loaded; + + SANE_Range win_x_range; + SANE_Range win_y_range; + + /* CMD_SET_WINDOW parameters we set: */ + int win_width; /* in 1200dpi points */ + int win_len; + double win_off_x; /* in inches (byte.byte) */ + double win_off_y; + int resolution; /* dpi indexed values */ + int composition; /* MODE_ */ + int doc_source; /* document source */ + int threshold; /* brightness */ + int compressionTypes; + + /* CMD_READ data. It is per block only, image could be in many blocks */ + int blocklen; /* image data block len (padding incl.) */ + int vertical; /* lines in block (padded) */ + int horizontal; /* b/w: bytes, gray/color: pixels (padded) */ + int final_block; + int pixels_per_line; + int bytes_per_line; + int ulines; /* up to this block including */ + int y_off; /* up to this block excluding*/ + int blocks; + + /* stat */ + int total_img_size; /* predicted image size */ + int total_out_size; /* total we sent to user */ + int total_data_size; /* total of what scanner sent us */ + + /* transport to use */ + transport *io; }; /* Transport abstract layer */ struct transport { - char* ttype; - - int (*dev_request) (struct device *dev, - SANE_Byte *cmd, size_t cmdlen, - SANE_Byte *resp, size_t *resplen); - SANE_Status (*dev_open) (struct device *dev); - void (*dev_close) (struct device *dev); - SANE_Status (*configure_device) (const char *devname, SANE_Status (*cb)(SANE_String_Const devname)); + char *ttype; + + int (*dev_request)(struct device *dev, + SANE_Byte *cmd, size_t cmdlen, + SANE_Byte *resp, size_t *resplen); + SANE_Status(*dev_open)(struct device *dev); + void (*dev_close)(struct device *dev); + SANE_Status(*configure_device)(const char *devname, SANE_Status(*cb)(SANE_String_Const devname)); }; /* USB transport */ -int usb_dev_request (struct device *dev, SANE_Byte *cmd, size_t cmdlen, SANE_Byte *resp, size_t *resplen); -SANE_Status usb_dev_open (struct device *dev); -void usb_dev_close (struct device *dev); -SANE_Status usb_configure_device (const char *devname, SANE_Status (*cb)(SANE_String_Const devname)); +int usb_dev_request(struct device *dev, SANE_Byte *cmd, size_t cmdlen, SANE_Byte *resp, size_t *resplen); +SANE_Status usb_dev_open(struct device *dev); +void usb_dev_close(struct device *dev); +SANE_Status usb_configure_device(const char *devname, SANE_Status(*cb)(SANE_String_Const devname)); /* TCP unicast */ -int tcp_dev_request (struct device *dev, SANE_Byte *cmd, size_t cmdlen, SANE_Byte *resp, size_t *resplen); -SANE_Status tcp_dev_open (struct device *dev); -void tcp_dev_close (struct device *dev); -SANE_Status tcp_configure_device (const char *devname, SANE_Status (*cb)(SANE_String_Const devname)); +int tcp_dev_request(struct device *dev, SANE_Byte *cmd, size_t cmdlen, SANE_Byte *resp, size_t *resplen); +SANE_Status tcp_dev_open(struct device *dev); +void tcp_dev_close(struct device *dev); +SANE_Status tcp_configure_device(const char *devname, SANE_Status(*cb)(SANE_String_Const devname)); /* device wants transfer buffer to be multiple of 512 */ #define USB_BLOCK_SIZE 512 #define USB_BLOCK_MASK ~(USB_BLOCK_SIZE - 1) -static inline int dataroom(struct device *dev) { - int tail = DATATAIL(dev); - if (tail < dev->dataoff) - return dev->dataoff - tail; - else if (dev->datalen == DATASIZE) { - return 0; - } else - return DATASIZE - tail; +static inline int dataroom(struct device *dev) +{ + int tail = DATATAIL(dev); + if (tail < dev->dataoff) + return dev->dataoff - tail; + else if (dev->datalen == DATASIZE) { + return 0; + } else + return DATASIZE - tail; } /* Functions from original xerox_mfp.c, used in -usb.c and -tcp.c */ -- cgit v1.2.3